hasattr hasattr() 函数是python的内置函数,用于判断对象是否包含对应的属性。 用法 hasattr(object, name) 参数 object:判断对象; name:属性名,字符串格式。 实例 class add: x=2, y=3, s