gpt4 book ai didi

python - Django shell 中的奇怪字符,箭头键不起作用

转载 作者:行者123 更新时间:2023-11-28 22:45:48 24 4
gpt4 key购买 nike

在不做任何异常操作后,我的 Django shell 坏了


(virtulenv)miki@blablabla >> python manage.py shell
Python 2.7.6 (default, Mar 22 2014, 22:59:56)
Type "copyright", "credits" or "license" for more information.

IPython 2.3.1 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.

In [1]:

它将空白符号显示为这些特殊字符,但当我在此处查看预览时,它没有显示,我将它的图像放在这里... wrong prompt

然而,这不是他唯一的问题。箭头和历史不起作用

在 [1] 中:^[[A^[[B^[[D^[[C

这也发生在普通 shell 中:


(virtulenv)miki@blablabla >> python manage.py shell --plain
Python 2.7.6 (default, Mar 22 2014, 22:59:56)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> ^[[A^[[B^[[D^[[C

我试过安装 readline 并重新编译 python。

想法?

最佳答案

我想通了...

Boss 将此添加到设置中,这是由于生产编码造成的。我添加了条件并在我的计算机上设置了环境变量,它是固定的...

if not os.environ.get("DISABLE_UTF8_REDEFINE"):
sys.stdout = codecs.getwriter('utf8')(sys.stdout)
sys.stderr = codecs.getwriter('utf8')(sys.stderr)

关于python - Django shell 中的奇怪字符,箭头键不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28128823/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com