【发布时间】:2012-04-16 22:11:51
【问题描述】:
我有一个字符串和一个对象列表:
gpl = "%(id)s : %(atr)s"
objects = [{'id':1, 'content':[{'atr':'big', 'no':2}]}, {'id':2, 'content': [{'atr':'small', 'no':3}]}]
for obj in objects:
for con in obj['content']:
print gpl %(obj,con)
我明白了:
TypeError: format requires a mapping
我将如何打印这个?我正在尝试打印:
1 : big
2 : small
谢谢
【问题讨论】:
标签: python string list object dictionary