📜  python hasattr 函数 - Python 代码示例

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

代码示例2
class Student:
    name = 'John'
    age  = 23
 
student = Student()
 
print('Does student has name?: ', hasattr(student, 'name'))
print('Does student has marks?: ', hasattr(student, 'marks'))

# Output:
# Does student has name?:  True
# Does student has marks?:  False