python Unicode轉ascii碼的一種方法

緣起 看到這樣的數據:Marek Čech、Beniardá怎樣變成相對應的ascii碼呢   解決 import unicodedata s = u"Marek Čech" #(u表示是unicode而非 ascii碼,不加報錯!) line = unicodedata.normalize('NFKD',s).encode('ascii','ignore') print line 結果   
相關文章
相關標籤/搜索