企业🤖AI Agent构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
### 导航 - [索引](../genindex.xhtml "总目录") - [模块](../py-modindex.xhtml "Python 模块索引") | - [下一页](__main__.xhtml "__main__ --- 顶层脚本环境") | - [上一页](sysconfig.xhtml "sysconfig --- Provide access to Python's configuration information") | - ![](https://box.kancloud.cn/a721fc7ec672275e257bbbfde49a4d4e_16x16.png) - [Python](https://www.python.org/) » - zh\_CN 3.7.3 [文档](../index.xhtml) » - [Python 标准库](index.xhtml) » - [Python运行时服务](python.xhtml) » - $('.inline-search').show(0); | # [`builtins`](#module-builtins "builtins: The module that provides the built-in namespace.") --- 内建对象 - - - - - - 该模块提供对Python的所有“内置”标识符的直接访问;例如,`builtins.open` 是内置函数的全名 [`open()`](functions.xhtml#open "open") 。请参阅 [内置函数](functions.xhtml#built-in-funcs) 和 [内置常量](constants.xhtml#built-in-consts) 的文档。 大多数应用程序通常不会显式访问此模块,但在提供与内置值同名的对象的模块中可能很有用,但其中还需要内置该名称。例如,在一个想要实现 [`open()`](functions.xhtml#open "open") 函数的模块中,它包装了内置的 [`open()`](functions.xhtml#open "open") ,这个模块可以直接使用: ``` import builtins def open(path): f = builtins.open(path, 'r') return UpperCaser(f) class UpperCaser: '''Wrapper around a file that converts output to upper-case.''' def __init__(self, f): self._f = f def read(self, count=-1): return self._f.read(count).upper() # ... ``` 作为一个实现细节,大多数模块都将名称 `__builtins__` 作为其全局变量的一部分提供。 \_\_builtins\_\_` 的值通常是这个模块或者这个模块的值 [`__dict__`](stdtypes.xhtml#object.__dict__ "object.__dict__") 属性。由于这是一个实现细节,因此Python的替代实现可能不会使用它。 ### 导航 - [索引](../genindex.xhtml "总目录") - [模块](../py-modindex.xhtml "Python 模块索引") | - [下一页](__main__.xhtml "__main__ --- 顶层脚本环境") | - [上一页](sysconfig.xhtml "sysconfig --- Provide access to Python's configuration information") | - ![](https://box.kancloud.cn/a721fc7ec672275e257bbbfde49a4d4e_16x16.png) - [Python](https://www.python.org/) » - zh\_CN 3.7.3 [文档](../index.xhtml) » - [Python 标准库](index.xhtml) » - [Python运行时服务](python.xhtml) » - $('.inline-search').show(0); | © [版权所有](../copyright.xhtml) 2001-2019, Python Software Foundation. Python 软件基金会是一个非盈利组织。 [请捐助。](https://www.python.org/psf/donations/) 最后更新于 5月 21, 2019. [发现了问题](../bugs.xhtml)? 使用[Sphinx](http://sphinx.pocoo.org/)1.8.4 创建。