如何在 Python 中讀寫 unicode(UTF-8)檔案?
現在推薦使用 io 模組,且其與 Python 3 的 open 語法相容:以下程式碼用於在 Python 中讀寫 unicode(UTF-8) 檔案
示例
import io with io.open(filename,'r',encoding='utf8') as f: text = f.read() # process Unicode text with io.open(filename,'w',encoding='utf8') as f: f.write(text)
廣告
資料結構
網路
關係型資料庫管理系統
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP