python gb2312 转 utf-8

# coding: utf-8
import chardet

f = open('d:/test.txt')
content = f.read()

ucontent = content.decode('gb2312').encode('utf-8-sig')
with open('d:/t.txt','w') as f2:
	f2.write(ucontent)
f.close()


你可能感兴趣的:(python gb2312 转 utf-8)