我需要制作一堆类变量,我想通过循环遍历这样的列表来实现:
vars=('tx','ty','tz') #plus plenty more class Foo(): for v in vars: setattr(no_idea_what_should_go_here,v,0)
可能吗?我不想让它们成为一个实例(在__init__中使用self),而是作为类变量.
python class class-variables
class ×1
class-variables ×1
python ×1