摘要: 元类(metaclass) # type()构建一个类 def f(self, name='python'): print('hello %s'% name) Test = type('Test', (object,), dict(show=f)) t = Test()t.show() # 另一种构 阅读全文
posted @ 2018-12-17 23:24 wk326 阅读(106) 评论(0) 推荐(0) 编辑
摘要: 1.以下程序输出结果是什么 a = 1 def fun(a): a = 2 fun(a) print (a) a = [] def fun(a): a.append(1) fun(a) print(a) 输出结果: 1 [1] 2.请简要说明什么是类变量,什么是实例变量,并观察以下程序的输出结果 答:实例变量必须在变量前添加self... 阅读全文
posted @ 2018-12-17 11:36 wk326 阅读(90) 评论(0) 推荐(0) 编辑