Python-Core-50-Courses icon indicating copy to clipboard operation
Python-Core-50-Courses copied to clipboard

第21课 代码是不是有问题

Open Cope9560 opened this issue 2 years ago • 2 comments

try:
    with open('guido.jpg', 'rb') as file1, open('吉多.jpg', 'wb') as file2:
        data = file1.read(512)
        while data:
            file2.write(data)
            data = file1.read()
except FileNotFoundError:
    print('指定的文件无法打开.')
except IOError:
    print('读写文件时出现错误.')
print('程序执行结束.')

在第一次循环后 read()没参数 是否代表读取剩下所有的内容,这样第一次拆分512字节是不是有没意义了? 初学者,如果说错了请无视

Cope9560 avatar Jul 22 '22 11:07 Cope9560

您好信以收到   将在下次登陆gmail或qqmail后进行回复

b11152 avatar Jul 22 '22 11:07 b11152

邮件已收到,辛苦了!!!

CHAMPIOM1 avatar Jul 22 '22 11:07 CHAMPIOM1