求助,复制图片上下二部份保存成另外的文件
程序代码:
""" 复制图片的上下二部分,保存成二个文件 """ import os filename = "./456.jpg" filesize = os.path.getsize(filename) def work(): with open(filename, "rb") as fr: with open('./top.jpg','wb') as fw1: data = fr.read(filesize//2) # 复制图片上半部分 fw1.write(data) with open('./bom.jpg','wb') as fw2: fr.seek(filesize // 2,0) # 复制图片下半部分 data = fr.read() fw2.write(data) work()
为何上半部份可以,下半部份却不行?