file_name = input('请输入需要打开的文件名:')
f = open(file_name)
print('文件的内容是:')
for each_line in f:
print(each_line)
运行之后出现报错如下:
请输入需要打开的文件名:1.txt
文件的内容是:
Traceback (most recent call last):
File "C:/Users/涤非/Desktop/test2.py", line 4, in <module>
for each_line in f:
UnicodeDecodeError: 'gbk' codec can't decode byte 0xff in position 0: illegal multibyte sequence
冰山点水
書劍
相关分类