|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
- 测试题:
- 0.
- 模块就是程序
- 1.
- import hello
- import hello as h
- from hello import hi
- from hello import * (不推荐)
- 2.
- 如上题
- 3.
- 在方法名前面加__,其实可以通过_类__方法名访问到.
- 如果是from xx import * 则可以加_拒绝,但如果是import xx或import xx._oo,则加入_也无效.
- 4.
- 打印B,因为覆盖了.
- 5.
- 会互相循环调用
- 动动手:
- 0.
- class const:
- def __init__():
- self.var = []
-
- def __setattr__(self,name,value):
- is_exist = 0
- is_upper = 0
-
- for each in self.var:
- if value == each:
- is_exist = 1
- raise '常量无法改变!'
-
- if value.isupper == True:
- is_upper = 1
- raise '常量名必须由大写字母组成!'
- if is_exist == 0 and is_upper == 1:
- self.var.append(value)
- self.name = value
复制代码 |
|