摘要: Student类本身需要绑定一个属性直接在class中定义属性,这种属性是类属性,归Student类所有:class Student(object): name = 'Student'类的所有实例都可以访问到类属性>>> s = Student() # 创建实例s>>> print(s.name) 阅读全文
posted @ 2018-02-23 10:07 夜游星 阅读(1154) 评论(0) 推荐(0)
摘要: 判断对象类型,使用type()函数 判断一个对象是否是函数使用types模块中定义的常量:>>> import types>>> type(abs)==types.BuiltinFunctionTypeTrue>>> type(lambda x: x)==types.LambdaTypeTrue>> 阅读全文
posted @ 2018-02-23 09:51 夜游星 阅读(177) 评论(0) 推荐(0)