标签: python django
我有这段代码
keys = {'speed','temp'}
我有像
object.subobj.speed和object.subobj.temp
object.subobj.speed
object.subobj.temp
我怎么循环
for key in keys print object.subobj.key
答案 0 :(得分:2)
for key in keys: print getattr(obj.subobj, key)