【问题标题】:Different output with the atom script package and python 3atom 脚本包和 python 3 的不同输出
【发布时间】: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


【解决方案1】:

我通过添加解决了它

  PYTHONIOENCODING=utf8

到运行选项中的环境变量

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-04-20
    • 1970-01-01
    相关资源
    最近更新 更多