gpt4 book ai didi

python - 每个 python 解释器都内置了 sys 模块是什么意思?

转载 作者:太空宇宙 更新时间:2023-11-03 12:53:46 25 4
gpt4 key购买 nike

我正在阅读官方的 Python 教程,上面写着

One particular module deserves some attention: sys, which is built into every Python interpreter.

但是,如果我启动 python 解释器并键入,例如 sys.path,我会得到一个 NameError: name sys is not defined

因此,如果我想访问它,我需要导入 sys

那么它“内置于每个 Python 解释器中”是什么意思?

最佳答案

简单来说就是

import sys

将成功,无论您使用的是哪个版本的 Python。它随每个 Python 安装一起提供。相反,例如,

import mpmath

除非您自己安装了 mpmath 包,否则它将失败,或者它与您正在使用的特定 Python 安装捆绑在一起。

关于python - 每个 python 解释器都内置了 sys 模块是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51277119/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com