主页
Python
Python setattr() 函数
demo_ref_setattr
运行 ❯
×
更改方向
保存代码
更改主题
class Person: name = "John" age = 36 country = "Norway" setattr(Person, 'age', 40) # The age property will now have the value: 40 x = getattr(Person, 'age') print(x)
40