论#coding=utf-8的位置

时间:2021-05-02 22:21:36

1.必须要在第一行或者第二行。
2.必须要在可执行代码和中文注释的前面。
3.如果页面没有中文,那么它只是一个普通注释,位置任意都行。

对的写法:

#coding=utf-8
#为未为
print "test"

#coding=utf-8
print "test"
#为未为

错的写法:

v=1
#coding=utf-8
#为未为
print "test"
print "test"
#coding=utf-8
#为未为
#为未为
#coding=utf-8
print "test"


#coding=utf-8 #为未为 print "test"