2019年1月12日

元类介绍

摘要: #储备知识 exec#参数1:字符串形式的命令#参数2:全局变量 (字典形式) 如果 不指定就使用globals#参数3:局部变量 (字典形式) 如果不指定就使用localsg = { 'x':1, 'm':2}l = {}exec('''global x,mx =10m = 20z = 3 ''' 阅读全文

posted @ 2019-01-12 21:24 别离 阅读(215) 评论(0) 推荐(0) 编辑

内置方法介绍

摘要: #判断obj是不是Foo的对象class Foo: passobj = Foo()#print(isinstance(obj, Foo))#判断Bar是不是Serives的子类class Serives(object): passclass Bar(Serives): pass#print(issu 阅读全文

posted @ 2019-01-12 18:00 别离 阅读(136) 评论(0) 推荐(0) 编辑

反射

摘要: #通过字符串映射到对象的属性class People: county = 'china' def __init__(self, name, age): self.name = name self.age = age def take(self): print('%s is taking'%self. 阅读全文

posted @ 2019-01-12 11:46 别离 阅读(78) 评论(0) 推荐(0) 编辑

导航