交互式输入编辑和历史替换 (Python Documentation_Ch14)

Interactive Input Editing and History Substitution (Python Documentation_Ch14)

在网上搜索 this doc 的答案:

Some versions of the Python interpreter support editing of the current input line and history substitution, similar to facilities found in the Korn shell and the GNU Bash shell. This is implemented using the GNU Readline library, which supports various styles of editing. This library has its own documentation which we won’t duplicate here.

也无法破解线路:

Completion of variable and module names is automatically enabled at interpreter startup so that the Tab key invokes the completion function; it looks at Python statement names, the current local variables, and the available module names.

任何人都可以提供一条简单的线来解释这条线。

编辑当前输入行是常见的做法。

例如,如果我使用命令提示符并执行:

cd C:\Us

并点击 Tab 它将自动填充为:

cd C:\Users\

它只是编辑了当前输入行。

同样查找历史也是一样的。如果我在命令提示符下执行以下操作:

> color b --> [Enter]
> # Now I have an empty command line
[Up Arrow]
> color b # Command prompt will fill the current line with what I just used.

Python可以通过查找变量和包来做同样的事情:

>>> import foobar
>>> fo [TAB] --> >>> foobar 

Python 自动填充 fofoobar 因为它知道我通过阅读代码导入了它。 它可以对变量执行相同的操作(通过阅读 python 代码来查找您定义的变量)。

>>> temp_var = 2
>>> te [TAB] --> >>> temp_var