python-3.x 抑制cmd警告消息

6rqinv9w  于 2023-11-20  发布在  Python
关注(0)|答案(1)|浏览(127)

当进入shell时,我总是从cmd2收到以下警告消息:

Desktop david$ python3 client.py
Readline features including tab completion have been disabled because
no supported version of readline was found. To resolve this, install
pyreadline on Windows or gnureadline on Mac.

字符串
这是我知道的事情,我不寻找或寻找解决这个问题.是否有一个选项来抑制此错误消息与cmd2?顺便说一下,这里是警告消息来自:https://github.com/python-cmd2/cmd2/blob/f5af7d32fb468012f793eb039e05a86292e0e5bf/cmd2/cmd2.py#L132-L146.

yvt65v4c

yvt65v4c1#

与其抑制警告(不是很好的做法),为什么不直接安装pyreadline(Windows)或gnureadline(Mac)来解决这个问题呢?
如果你坚持压制警告,

warnings.filterwarnings("ignore", message="Readline features including tab completion have been disabled")

字符串
可能会奏效。
我强烈建议不要隐藏所有警告。

相关问题