这个问题已经在这里有了答案:????????????>????????????Sublime Text 2 encoding error with python3 build????????????????????????????????????2个
#-*- encoding:utf-8 -*-
from __future__ import (absolute_import, division, print_function,
unicode_literals)
text = "我们的世界充满了未知数." # Chinese
print( type(text) ) # unicode
print(text.encode('utf-8'))
print(text) # an error occurs in sublime
python的版本是2.7.6.操作系统是Linux Mint17.bash中的$LANG是en_US.UTF-8.在崇高的文字中,Ctrl B用于运行此玩具程序.输出为:
Traceback (most recent call last):
我们的世界充满了未知数.
File "~/test.py", line 9, in
print(text) # an error occurs
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-11: ordinal not in range(128)
[Finished in 0.0s with exit code 1]
[shell_cmd: python -u "~/test.py"]
要么
Traceback (most recent call last):
File "~/test.py", line 9, in
我们的世界充满了未知数.
print(text) # an error occurs
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-11: ordinal not in range(128)
[Finished in 0.0s with exit code 1]
[shell_cmd: python -u "~/test.py"]
在bash中,eigherpython test.py或python -u test.py正确运行:
$python test.py
我们的世界充满了未知数.
我们的世界充满了未知数.
$python -u test.py
我们的世界充满了未知数.
我们的世界充满了未知数.
这真的让我感到奇怪.有什么方法可以正确地以崇高的文字运行程序吗?
>崇高和bash的环境之间有什么区别吗?
>为什么崇高文本中的输出乱序?