📅  最后修改于: 2022-03-11 14:45:25.055000             🧑  作者: Mango
class Student:
name = 'John'
student = Student()
# Set 'age' attribute to 23
setattr(student, 'age', 23)
print('Student name: ', student.name)
print('Student age: ', student.age)
# Output
# Student name: John
# Student age: 23