python3开头如何设置utf-8

845次阅读
没有评论

python3开头如何设置utf-8

编码格式1:

在源文件第一行或者第二行定义:

# coding=<encoding name>

例如:

# coding=utf-8

python3开头如何设置utf-8

编码格式2:(这种最流行)

格式如下:

#!/usr/bin/python 
# -*- coding: <encoding name> -*-

例如:

#!/usr/bin/python 
# -*- coding: utf-8 -*-

python3开头如何设置utf-8

编码格式3:(如果使用了vim)

#!/usr/bin/python 
# vim: set fileencoding=<encoding name> :

例如:

#!/usr/bin/python
# vim: set fileencoding=utf-8 :

python3开头如何设置utf-8

神龙|纯净稳定代理IP免费测试>>>>>>>>天启|企业级代理IP免费测试>>>>>>>>IPIPGO|全球住宅代理IP免费测试

相关文章:

版权声明:wuyou2021-06-21发表,共计301字。
新手QQ群:570568346,欢迎进群讨论 Python51学习