📜  python getattr 函数 - Python 代码示例

📅  最后修改于: 2022-03-11 14:46:29.375000             🧑  作者: Mango

代码示例1
class Student:
    name = 'John'
    age  = 24
  
student = Student()
  
print('Student name: ', getattr(student, 'name'))
print('Student age: ', getattr(student, 'age'))
  
# Output
# Student name:  John
# Student age:  24