我有这个代码keys = {'speed','temp'}我有像这样的变量object.subobj.speed和object.subobj.temp我该如何循环for key in keys print object.subobj.key 最佳答案 for key in keys: print getattr(obj.subobj, key)