【发布时间】:2019-05-07 09:07:24
【问题描述】:
我在 macOS Mojave 上使用 atom 编辑器和 script 包。
我创建了一个文件,其中包含带有德语变音符号的印刷品:
print(hellö)
我直接在Atom中执行文件时,出现如下错误信息:
Traceback (most recent call last):
File "/Users/hambert/runScriptAtom.py", line 1, in <module>
print("hell\xf6")
UnicodeEncodeError: 'ascii' codec can't encode character '\xf6' in position 4: ordinal not in range(128)
[Finished in 0.16s]
在终端中
hambert$ python3 /Users/hambert/runScriptAtom.py
hellö
我检查了版本
import sys
print(sys.version)
完全一样
【问题讨论】:
-
Atom 控制台的编码可能有一个设置。找到它并将其设置为 UTF-8 而不是 ASCII。
标签: python-3.x utf-8 ascii atom-editor