import codecs
with codecs.open('file.txt', 'r', encoding='gbk') as f, codecs.open('file.txt', 'w', encoding='utf-8') as wf:
for line in f.readlines():
# newline = '{}\t{}\n'.format((lines[2]).encode('gbk'), (lines[3]).encode('gbk'))
wf.write(line)
记录一下转码方式,查了很多种方法,例如:
https://www.cnblogs.com/xuchunlin/p/7253954.html
中使用的decode再encode方式,发现打开后还是GBK编码.
最后成功完成转码的方式:
https://blog.youkuaiyun.com/index20001/article/details/78974865?utm_source=blogxgwz1
现在的小说网站都是GBK真是够了.