每日python(7)

使用 % 将字典中的value嵌入到字符串中对应的key值中

dd = {"a":1,"b":2,"c":3}
txt = "this is a test : a is %(a)s, b is %(b)s, c is %(c)s "
print txt % dd

结果为:

 this is a test : a is 1, b is 2, c is 3  

 

posted @ 2015-09-15 13:01  ivywenyuan  阅读(106)  评论(0编辑  收藏  举报