python3开头如何设置utf-8
爱喝马黛茶的安东尼
2021-03-18 17:30:0235754浏览 · 0收藏 · 0评论
编码格式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 :
(推荐操作系统:windows7系统、Python 3.9.1,DELL G3电脑。)
关注公众号,随时随地在线学习