【发布时间】:2021-07-02 11:46:11
【问题描述】:
我有一个字符串和一个字典列表:
body = "Next, we wil give you detailed information about each case: %s"
feature_list = [{'FEATURE_NAME': 'FT02', 'Number of users who tested it ': 30, 'Number of problems detected' : 2},
{'FEATURE_NAME': 'SW045', 'Number of users who tested it ': 5, 'Number of problems detected' : 0}
{'FEATURE_NAME': 'SW04', 'Number of users who tested it ': 23, 'Number of problems detected' : 8}]
我想创建一个这样的新字符串:
newbody = """
Next, we wil give you detailed information about each case :
{'FEATURE_NAME': 'FT02', 'Number of users who tested it ': 30, 'Number of problems detected' : 2}
{'FEATURE_NAME': 'SW045', 'Number of users who tested it ': 5, 'Number of problems detected' : 0}
{'FEATURE_NAME': 'SW049', 'Number of users who tested it ': 23, 'Number of problems detected' : 8}]
"""
我试图遍历列表,但这样我只能得到字符串中的最后一个字典。我知道可以按原样给出列表,但这看起来非常丑陋且难以阅读。
【问题讨论】:
-
你能告诉我们你是如何尝试迭代的,以及你得到了什么,与你“想要”得到的相比吗?
标签: python string dictionary