python C 为什么最后一个命令变量“_”不出现在dir()中?
发布时间:2023-12-17 01:45:05 所属栏目:Python 来源:DaWei
导读: 参见英文答案 >
Is the single underscore “_” a built-in variable in Python?3个
在Windows上启动Python 2.7解释器后的第一行:
>>> dir()
['__builtins__','__doc__','_
Is the single underscore “_” a built-in variable in Python?3个
在Windows上启动Python 2.7解释器后的第一行:
>>> dir()
['__builtins__','__doc__','_
参见英文答案 >
Is the single underscore “_” a built-in variable in Python?3个
输入dir()命令后,应定义特殊变量_: >>> _ ['__builtins__','__package__']但是,即使在输入_之后,当我尝试使用dir()列出交互式命名空间中的所有名称时,它也不会显示: >>> dir() ['__builtins__','__package__']如果解释器不在解释器的命名空间中,解释器如何识别它? 解决方法 _进入内置命名空间,而不是全局变量. >>> import __builtin__ >>> 3 3 >>> __builtin__._ 3dir() doesn’t list built-ins: Without arguments,return the list of names in the current local scope. 内置范围与您运行dir()的范围不同. (编辑:莱芜站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
推荐文章
站长推荐