Python读取文件时出现UnicodeDecodeError

运行下面code时

with open('style.css','r',encoding='utf-8') as f:
	for line in f:
		print(line)

出现错误

UnicodeDecodeError: 'gbk' codec can't decode byte 0x9d in position 1947: illegal multibyte sequence

将open代码改为

with open('style.css','r',encoding='utf-8') as f:
	for line in f:
		print(line)
转载自网络的内容未用作任何商业用途,如有侵权请告知删除!
本站的原创文章请在转载时注明来源<《芯片版图》

发表评论