python讀寫文件字符集

操做I/O的能力是由操做系統的提供的,每一種編程語言都會把操做系統提供的低級C接口封裝起來供開發者使用,Python也不例外。編程

 讀寫文件是須要請求操做系統去操做磁盤的  因此默認的編碼就是你平臺的編碼 。
encoding is the name of the encoding used to decode or encode the
file. This should only be used in text mode. The default encoding is
platform dependent, but any encoding supported by Python can be
passed. See the codecs module for the list of supported encodings.
 你平臺的編碼是gbk 可是你要打開的文件是utf-8  因此就報錯了
相關文章
相關標籤/搜索