每日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
使用 % 将字典中的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