python C 为什么最后一个命令变量“_”不出现在dir()中?
发布时间:2023-12-17 01:45:56 所属栏目: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()的范围不同. (编辑:4S站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- Python语言中的函数range()没有给出预期的结果
- python – Flask会话变量在请求之间不存在
- python – matplotlib – 传说在单独的子图
- ValueError:参数必须是密集张量–Python和TensorFlow
- 用于__str__和方法解析顺序的Python Mixin
- python – 告诉PyCharm代码生成的类字段
- python-2.7 – OpenCV:libdc1394错误:无法初始化libdc139
- 设置python中命名参数的默认设置
- python – 启动py.test后,在读取请求的数据流后无法访问正文
- python – 在Tkinter中动态创建菜单. (lambda表达式?)
推荐文章
站长推荐