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