[英]Set up Notepad++ and NppExec to print unicode characters from python
I have an utf-8 encoded file cjk.py
: 我有一个utf-8编码的文件cjk.py
:
print("打印")
Unsurprisingly, running python cjk.py
yields 不出所料,运行python cjk.py
产生
Traceback (most recent call last):
File "cjk.py", line 1, in <module>
print('\u6253\u5370')
File "C:\Python33\lib\encodings\cp850.py", line 19, in encode
return codecs.charmap_encode(input,self.errors,encoding_map)[0]
UnicodeEncodeError: 'charmap' codec can't encode characters in position 0-1: character maps to <undefined>
Yet running idle -r cjk.py
works perfectly: 然而运行idle -r cjk.py
完美运行:
打印
Can I configure notepad++'s NppExec plugin to behave like Idle? 我可以配置notepad ++的NppExec插件,使其表现得像空闲吗? I've trying setting input and output encoding to UTF-8, to no avail (same exception as when running python cjk.py
from the console) 我正在尝试将输入和输出编码设置为UTF-8,但无效(与从控制台运行python cjk.py
时相同的异常)
I had the same problem and fixed it. 我有同样的问题并修复它。
Add env_set PYTHONIOENCODING=utf-8
just below C:\\Python27\\python.exe "$(FULL_CURRENT_PATH)"
in the dialog box when you press F6 . 按F6时,在对话框中的C:\\Python27\\python.exe "$(FULL_CURRENT_PATH)"
下面添加env_set PYTHONIOENCODING=utf-8
。
Worked like a charm for me, hope it helps. 对我来说就像一个魅力,希望它有所帮助。
Source: http://sourceforge.net/p/npp-plugins/discussion/672146/thread/d94ff609/ 资料来源: http : //sourceforge.net/p/npp-plugins/discussion/672146/thread/d94ff609/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.