theodorus

theodorus

V2EX member #178337, joined on 2016-06-21 08:04:39 +08:00
Per theodorus's settings, the topics list is hidden
Deals info, including closed deals, is not hidden
theodorus's recent replies
@Sasasu 我将 python 文件设置为 utf-8 编码之后并且也按照你说的做了。可是还是无法打印出汉字。不知为何。在 mac 自带的 terminal 里面可以打出汉字。通过 ssh 连接 debian 里面却不能。我不知为何, 请问你能否告诉我原因吗?
@billlee 我应该发现问题了。麻烦你们了。应该是我必须设置 python 为 utf-8 编码。否则会自动设为 ascii 编码。我去多学习学习, 不随便发帖了。抱歉各位。
@billlee 没错我终端是 ssh 连接。然后编码如下
[root@Debian 4test]#locale -a
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_COLLATE to default locale: No such file or directory
C
C.UTF-8
POSIX
en_US.utf8


我的终端是 mac 的 terminal 已经设置为支持中文的 GBK, UTF-8 等格式编码。能够显示中文。使用 ls 命令可以看到中文文件名称。也可输入。

但是 python 无法解析这个让我很头疼。
@billlee 得得得。既然都这么说, 那我还是再试试吧。这玩意困扰我很久了。我用的是 minial 版的。
[root@Debian 4test]#export LANG=zh_CN.UTF-8
[root@Debian 4test]#./test.py
Traceback (most recent call last):
File "./test.py", line 3, in <module>
print u"\u5929"
UnicodeEncodeError: 'ascii' codec can't encode character u'\u5929' in position 0: ordinal not in range(128)
[root@Debian 4test]#


我还试了 LC_ALL 等。还有 dpkg-reconfigure locales 等命令。可是不行啊。。。感觉要安装中文字体库?
@billlee 假如你的 LANG 和 LC_ALL 是 en_US.UTF-8 的话会报错。
@tomczhen 我当然问啦。我上了谷歌, 鸟哥的站。我用了那个 dpkg-reconfigure locales 可是不行啊。我编码理解还好。主要是不知道怎么设置啊。
@est 别别别。人是丢了, 学点东西回去就可以了 233
Aug 21, 2016
Replied to a topic by theodorus Python 求比较好的 Python 库文档推荐。
@hasdream 受教了。 thx
Aug 21, 2016
Replied to a topic by theodorus Python 求比较好的 Python 库文档推荐。
@all 谢谢各位。
About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1250 Online   Highest 6679   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 20ms · UTC 16:55 · PVG 00:55 · LAX 09:55 · JFK 12:55
♥ Do have faith in what you're doing.