加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Python > 正文

模块在Python中有类型吗?

发布时间:2020-12-20 11:55:22 所属栏目:Python 来源:网络整理
导读:我正在读 PEP338.有些话困惑我: If the module is found,and is of type PY_SOURCE or PY_COMPILED ,then the command line is effectively reinterpreted from python options -m module args to python options filename args . 模块在Python中有类型吗?
我正在读 PEP338.有些话困惑我:

If the module is found,and is of type PY_SOURCE or PY_COMPILED,then the command line is effectively reinterpreted from python <options> -m <module> <args> to python <options> <filename> <args> .

模块在Python中有类型吗?

解决方法

模块可以从不同的来源加载.作者参考了加载模块的2个特定来源,参见 imp module documentation:

imp.PY_SOURCE
The module was found as a source file.

[…]

imp.PY_COMPILED
The module was found as a compiled code object file.

[…]

imp.C_EXTENSION
The module was found as dynamically loadable shared library.

这些值用于imp.get_suffixes() function的返回值等.

PEP声明只支持从源(.py文件)和字节码缓存文件(.pyc)加载的模块; -m开关不支持C扩展模块(通常是.so或.dll动态加载的库).

生成的模块对象仍然只是一个模块对象;您找到的文本中的单词类型不是指Python的类型系统.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读