readline
— GNU readline 接口
¶
The
readline
模块定义了促进 Python 解释器补全和读取/写入历史文件的很多函数。可以直接使用此模块,或凭借
rlcompleter
模块,支持交互提示补全 Python 标识符。使用此模块做出的设置会影响解释器交互提示的行为和提供提示通过内置
input()
函数。
可以凭借初始化文件配置 readline 键绑定,通常
.inputrc
在您的 Home (主) 目录。见
readline 初始文件
在 GNU readline 手册了解该文件的格式和可允许构造的有关信息,及 readline 库的一般能力。
可用性 : not Android, not iOS, not WASI.
This module is not supported on mobile platforms or WebAssembly 平台 .
注意
可以实现底层 readline 库 API 通过
editline
(
libedit
) library instead of GNU readline. On macOS the
readline
模块检测运行时在使用哪个库。
配置文件对于
editline
is different from that of GNU readline. If you programmatically load configuration strings you can use
backend
to determine which library is being used.
若使用
editline
/
libedit
在 macOS 仿真 readline,位于 Home (主) 目录的初始化文件名为
.editrc
。例如,以下内容在
~/.editrc
将打开
vi
键绑定和 Tab 补全:
python:bind -v python:bind ^I rl_complete