在很多地方看到 #-*- 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> :