用户:
谛霖查看:6 回复:4 评论:6 创建时间:2023-06-18T17:04:42
【作品展示】

【作品介绍】
《笨办法学python》上的教学程序,一开始是能运行的,运行了几次就报错了,以下是报错内容翻译:从ss.txt复制到ss.txt
追踪(最近一次通话):
文件“ex17.py”,第10行,在中
indata=in.file.read()
UnicodeDecodeError:“gbk”编解码器无法解码位置2中的字节0x8a:非法的多字节序列
【作品源代码】
from sys import argv
from os.path import exists
script, from_file, to_file = argv
print(f"copying from {to_file} to {to_file}")
#we could do these two on one line,now?
in_file = open(from_file)
indata = in_file.read()
print(f'the input file is {len(indata)}bytes long')
print(f'does the output file exist?{exists(to_file)}')
print('ready,hit return to continue, ctrl-c to abort')
input()
out_file = open(to_file, 'w')
out_file.write(indata)
print("alright,all done")
out_file.close()
in_file.close()
【提示】
部分含有Python第三方库相关内容的作品,在海龟编辑器网页端无法运行哦!如遇到这种情况,可以打开下面的链接,下载海龟编辑器客户端:
https://python.codemao.cn