16
我有一个字符串和对象的列表:类型错误:格式需要映射
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
谢谢
感谢它的工作! – Neeran 2012-04-03 09:18:54