程序代码:#!/usr/bin/envpython3#-*-coding:utf-8-*-withopen('gbk.txt','r',encoding='gbk')asf:print(f.read())其中gbk.txt打开应该是“测试”两个中文字。在SublimeText3中间运行,得到的结果如下:Traceback(mostrecentcalllast):File"/Users/Jane/PycharmProjects/python-learning/1030.py",line14,inprint(f.read())UnicodeEncodeError:'ascii'codeccan'tencodecharactersinposition0-2:ordinalnotinrange(128)[Finishedin0.1swithexitcode1]请问该如何解决?
添加回答
举报
0/150
提交
取消