Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何阻止用户输入出现在cmd模块的历史记录中?_Python_Python 3.x_Python Cmd - Fatal编程技术网

Python 如何阻止用户输入出现在cmd模块的历史记录中?

Python 如何阻止用户输入出现在cmd模块的历史记录中?,python,python-3.x,python-cmd,Python,Python 3.x,Python Cmd,考虑这个使用模块的最小程序: 以下是与此程序的交互示例: (Cmd) input String: Hello! Hello! (Cmd) 现在的问题是,按下键盘上的“向上”按钮时,最后一个历史记录项来自用户输入(即Hello!),而不是shell提示(即input) 问题是:如何仅获取在shell提示符下输入的命令的历史记录(没有使用input()输入的输入历史记录)?历史记录功能与cmd模块没有任何关系;它来自Python在可能的情况下用于input()的readline库。您可以操纵它的

考虑这个使用模块的最小程序:

以下是与此程序的交互示例:

(Cmd) input
String: Hello!
Hello!
(Cmd) 
现在的问题是,按下键盘上的“向上”按钮时,最后一个历史记录项来自用户输入(即
Hello!
),而不是shell提示(即
input


问题是:如何仅获取在shell提示符下输入的命令的历史记录(没有使用
input()
输入的输入历史记录)?

历史记录功能与
cmd
模块没有任何关系;它来自Python在可能的情况下用于
input()
readline
库。您可以操纵它的历史记录列表,以除去不需要的项,例如:请参阅。
(Cmd) input
String: Hello!
Hello!
(Cmd)