变量__spec__来自哪里?
$ brew install python3
$ python3
Python 3.4.2 (default, Jan 5 2015, 11:57:21)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.56)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
# Under Python 2.7.x this gives a NameError
>>> None is __spec__
True
Run Code Online (Sandbox Code Playgroud)
从Python语言参考,第5部分:导入系统(强调我的):
__spec__必须将该属性设置为导入模块时使用的模块规范.这主要用于内省和重新加载.__spec__适当的设置同样适用于在解释器启动期间初始化的模块.唯一的例外是__main__,__spec__在某些情况下,where 设置为None.版本3.4中的新功能.
| 归档时间: |
|
| 查看次数: |
1445 次 |
| 最近记录: |