相关疑难解决方法(0)

在Python源代码中使用utf-8编码

$ cat bla.py 
u = unicode('d…')
s = u.encode('utf-8')
print s
$ python bla.py 
  File "bla.py", line 1
SyntaxError: Non-ASCII character '\xe2' in file bla.py on line 1, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details
Run Code Online (Sandbox Code Playgroud)

如何在源代码中声明utf-8字符串?

python encoding utf-8 character-encoding

404
推荐指数
2
解决办法
82万
查看次数

标签 统计

character-encoding ×1

encoding ×1

python ×1

utf-8 ×1