发布时间:2019-09-25 08:24:31编辑:auto阅读(1974)
缘起:
[root@CentOS7 code]# python multi_thread_mfw.py
File "multi_thread_mfw.py", line 138
SyntaxError: Non-ASCII character '\xe5' in file multi_thread_mfw.py on line 138, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details
写完python代码运行时,报类似SyntaxError: Non-ASCII character ‘\xe5’ in file *.py,
基本可以断定,python文件开头未设置coding=utf-8。
#!/usr/bin/python
# coding=utf-8
# TODO: anything
或者:
#!/usr/bin/python
# -*- coding:utf-8 -*-
# TODO: anything
vim中对python语法高亮,正则匹配规则:
\%^.*\n.∗\?#.*coding[:=]\s*[0-9A-Za-z-_.]\+.*$
PEP-0263 关于的编码声明的解释
上一篇: Python 用for循环实现猜数字游戏
下一篇: Python持久化管理 pickle
47760
46269
37152
34655
29246
25906
24778
19878
19441
17933
5730°
6335°
5853°
5903°
7004°
5841°
5860°
6372°
6331°
7695°