English document:
hasattr(object, name)
AttributeError or not.)
#定义类A >>> class Student: def __init__(self,name): self.name = name >>> s = Student('Aim') >>> hasattr(s,'name') #a含有name属性 True >>> hasattr(s,'age') #a不含有age属性 False
The above is the detailed content of Detailed introduction to Python's built-in hasattr function. For more information, please follow other related articles on the PHP Chinese website!