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  因此就报错了
相关文章
相关标签/搜索