您的位置:首页 > 编程语言 > Python开发

Python学习笔记之疑问 6:#coding=utf-8 与#-*- coding: utf-8 -*-的区别

2013-10-05 21:57 696 查看
在很多地方看到 #-*- coding: utf-8 -*- 这种写法,不知道他们有什么区别。

实际上,对于编译器来说,他们是一样的,区别在于他们对不同的编辑器对他的识别可能有问题。

常用的方法:

placed into the source files either as first or second
line in the file, such as:

# coding=<encoding name>

or (using formats recognized by popular editors)

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

or

#!/usr/bin/python
# vim: set fileencoding=<encoding name> :
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: