2010年12月18日 星期六

中文顯示

chinese = u"中文!"
print chinese


--------------------------------------------------------
加入 wxpython 的練習,建立一個中文標題視窗
-------------------------------------------------------
mytitle = u"練習"
import wx # 導入wxPython
class App(wx.App):#子類化wxPython
    def OnInit(self): #定義一個應用程序的初始化方法
        frame = wx.Frame(parent=None, title=mytitle)
        frame.Show()
        return True
app = App() #創建一個應用程序類的實例
app.MainLoop() #進入這個應用程序的主事件循環

-------------------------------------
讀取utf8檔案
------------------------------------------
import codecs
fileObj = codecs.open( "someFile", "r", "utf-8" )
u = fileObj.read() # Returns a Unicode string from the UTF-8 bytes in the file
-------------------------------------------------------------
以萬用碼Unicode編寫python

special comment in the first or second lines of your script:
# -*- coding: utf-8 -*-

沒有留言:

張貼留言