Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个对象列表。我想调用该列表中对象的变量或函数。(在这个问题中有这么多的基本关键字,很难找到解决方案或指南!)
例如:
for each in current_staff_list: print(current_staff_list[each].variable_name)
这样做的正确语法是什么?
each已经是正确的元素:
each
for each in current_staff_list: print(each.variable_name)
Pythonfor循环为您提供元素本身,而不是序列的索引。
for