懵懂的菜鸟

Stay hungry,Stay foolish.

导航

2017年8月22日 #

python读取文件另存为

摘要: 1 fr = open(filename_r,encoding='cp852') 2 w2 = open(filename_w,'a')#a代表追加 w代表重写 3 4 for line in fr: 5 w2.write(line) 6 fr.close() 7 w2.close( ) 阅读全文

posted @ 2017-08-22 10:32 懵懂的菜鸟 阅读(9887) 评论(0) 推荐(0) 编辑

python 编码方式大全 fr = open(filename_r,encoding='cp852')

摘要: 7.8.3. Standard Encodings Python comes with a number of codecs built-in, either implemented as C functions or with dictionaries as mapping tables. The 阅读全文

posted @ 2017-08-22 10:22 懵懂的菜鸟 阅读(12071) 评论(0) 推荐(0) 编辑

python 修改文件编码方式

摘要: 详细解释: 阅读全文

posted @ 2017-08-22 09:52 懵懂的菜鸟 阅读(16379) 评论(0) 推荐(1) 编辑

python encode和decode

摘要: 字符串编码常用类型:utf-8,gb2312,cp936,gbk等。 Python中,我们使用decode()和encode()来进行解码和编码 在python中,使用unicode类型作为编码的基础类型。即 decode encode str > unicode >str 如上面代码,str\st 阅读全文

posted @ 2017-08-22 09:49 懵懂的菜鸟 阅读(444) 评论(0) 推荐(0) 编辑