f = open('threeking.txt', 'r', encoding="utf-8").read()
报错
方案1:
f = open('threeking.txt', 'r', encoding="gb18030").read()
方案2:
f = open('file.txt', 'r', encoding='utf-8')
txt =f.read()
if txt.startswith(u'\ufeff'):
content = txt.encode('utf8')[3:].decode('utf8')
方案3
f = open('file.txt', 'r', encoding='utf-8_sig')