python3开头如何设置utf-8
编码格式1:
在源文件第一行或者第二行定义:
# coding=<encoding name>
例如:
# coding=utf-8
相关推荐:《Python基础教程》
编码格式2:(这种最流行)
格式如下:
#!/usr/bin/python # -*- coding: <encoding name> -*-
例如:
#!/usr/bin/python # -*- coding: utf-8 -*-
编码格式3:(如果使用了vim)
#!/usr/bin/python # vim: set fileencoding=<encoding name> :
例如:
#!/usr/bin/python # vim: set fileencoding=utf-8 :
您可能感兴趣的文章:
Python3 startswith()方法
Python3 bytes.decode()方法
python3开头如何设置utf-8
Python3 encode()方法
Python 中文编码
Python3 os.isatty() 方法
python3怎么输出中文
Python3 os.mkdir() 方法
Python3 CGI编程
Python3 File 方法