python-3.x - atom 脚本包和 python 3 的不同输出
问题描述
我在 macOS Mojave 上使用 atom 编辑器和脚本包。
我创建了一个文件,其中包含带有德语变音符号的打印:
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)
完全一样
解决方案
我通过添加解决了它
PYTHONIOENCODING=utf8
到运行选项中的环境变量
推荐阅读
- java - Java:通过在初始化期间返回现有类来防止重复类
- frameworks - forkdelta 的前端使用什么框架?
- c++ - 如何在单击按钮的确切时刻获取小部件的值 FLTK
- node.js - 有限的帖子请求
- list - 获取列表中的项目数
- excel - 调试代码以将选项卡从一个工作簿移动到另一个作为循环的一部分从主管打开的工作簿
- java - 使用 ResultSet .getArray() 时出现错误“java.sql.SQLException:结果集结束后”
- clang-format - clang-format 展开空初始化程序
- javascript - 从 Node Js Server + Express 下载文件
- sql-server - 当我们为现有表添加标识列时排序如何工作