math.py 和 sys.py 在哪里? [英] Where are math.py and sys.py?

查看:63
本文介绍了math.py 和 sys.py 在哪里?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Python33/Lib 中找到了所有其他模块,但我找不到这些.我相信还有其他人失踪"了,但这些是我唯一注意到的.当我导入它们时,它们工作得很好,我就是找不到它们.我检查了 sys.path 并且它们不在那里.它们是内置的还是什么?

解决方案

mathsys 模块是内置的——为了提高速度,它们被写入C 并直接合并到 Python 解释器中.

要获取所有内置函数的完整列表,您可以运行:

<预><代码>>>>导入系统>>>sys.builtin_module_names

在我的机器上,结果如下:

__builtin____主要的___ast_二等分_编解码器_codecs_cn_codecs_hk_codecs_iso2022_codecs_jp_codecs_kr_codecs_tw_collections_csv_functools_heapq_hotshot_io_json_locale_lsprof_md5_多字节编解码器_随机的_sha_sha256_sha512_sre_结构_子进程_symtable_警告_weakref_winreg大批音频操作二进制文件泡菜字符串IO数学约会时间错误号例外future_builtinsGC图像操作小鬼迭代工具元帅数学映射msvcrtnt操作员解析器信号索道系统线时间xx亚型压缩导入zlib

I found all the other modules in Python33/Lib, but I can't find these. I'm sure there are others "missing" too, but these are the only ones I've noticed. They work just fine when I import them, I just can't find them. I checked sys.path and they weren't anywhere in there. Are they built-in or something?

解决方案

The math and sys modules are builtins -- for purposes of speed, they're written in C and are directly incorporated into the Python interpreter.

To get a full list of all builtins, you can run:

>>> import sys
>>> sys.builtin_module_names

On my machine, that results in the following list:

__builtin__
__main__
_ast
_bisect
_codecs
_codecs_cn
_codecs_hk
_codecs_iso2022
_codecs_jp
_codecs_kr
_codecs_tw
_collections
_csv
_functools
_heapq
_hotshot
_io
_json
_locale
_lsprof
_md5
_multibytecodec
_random
_sha
_sha256
_sha512
_sre
_struct
_subprocess
_symtable
_warnings
_weakref
_winreg
array
audioop
binascii
cPickle
cStringIO
cmath
datetime
errno
exceptions
future_builtins
gc
imageop
imp
itertools
marshal
math
mmap
msvcrt
nt
operator
parser
signal
strop
sys
thread
time
xxsubtype
zipimport
zlib

这篇关于math.py 和 sys.py 在哪里?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆