-
Notifications
You must be signed in to change notification settings - Fork 5.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG/Help] 运行cli_demo.py时报错UnicodeDecodeError: 'utf-8' codec can't decode byte #493
Comments
@MaiziXiao |
我也遇到了这个问题,似乎input("\n用户:")这句会引起这个错误。请问有解决办法吗? |
这个是input函数的问题。在输入错误的时候使用了退格键(backspace)。一次退格只删除一个char,一般utf8的汉字是3个char。所以需要按3次才能删除输入错误的字。 补充一个方法: |
目前的代码中直接 错误代码如下:
|
readline是python3的内置模块,应该不需要安装。
|
感谢点拨,经过一系列的搜索,应该安装 somehow,我这儿没有内置,诡异。 |
同样遇到 No module named 'readline',环境 python3.8.0 Window10。安装 pyreadline3 解决,感谢~ |
在liunx环境下在代码中添加import readline,问题仍然存在 |
请问大佬,try,catch应该加在哪里,有示例吗? |
import readline更方便解决。安装 pyreadline3 |
Is there an existing issue for this?
Current Behavior
Traceback (most recent call last):
File "cli_demo.py", line 57, in
main()
File "cli_demo.py", line 33, in main
query = input("\n用户:")
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe6 in position 6: invalid continuation byte
Expected Behavior
No response
Steps To Reproduce
python cli_demo.py
The text was updated successfully, but these errors were encountered: