代码: 全选
#!/usr/bin/env python
#
# _*_ coding: utf-8 _*_
import Tkinter
top=Tkinter.Tk()
quit=Tkinter.Button(top,text='hello你好 world',command=top.quit)
quit.pack()
Tkinter.mainloop()
代码: 全选
#!/usr/bin/env python
#
# _*_ coding: utf-8 _*_
import Tkinter
top=Tkinter.Tk()
quit=Tkinter.Button(top,text='hello你好 world',command=top.quit)
quit.pack()
Tkinter.mainloop()
代码: 全选
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
#
没错。写在头部就可以了。虽然是#开头,也算是注释,你可以把他当作特殊的注释,它是用来标记文档编码类型的。planwolf 写了:谢谢
但有点不明白,
# -*- coding: UTF-8 -*-
用#开头? 写在注释里面
代码: 全选
#!/bin/env python
# -*- coding: utf-8 -*-
import sys
reload(sys)
sys.setdefaultencoding("utf-8")
代码: 全选
#!/usr/bin/python
# -*- coding: utf-8 -*-
print 'Hi,Python!\n我喜欢Python~'
一定要写在前两行才可以planwolf 写了:谢谢
但有点不明白,
# -*- coding: UTF-8 -*-
用#开头? 写在注释里面