Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

第21课 代码是不是有问题 #38

Open
Cope9560 opened this issue Jul 22, 2022 · 2 comments
Open

第21课 代码是不是有问题 #38

Cope9560 opened this issue Jul 22, 2022 · 2 comments

Comments

@Cope9560
Copy link

Cope9560 commented Jul 22, 2022

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字节是不是有没意义了?
初学者,如果说错了请无视

@b11152
Copy link

b11152 commented Jul 22, 2022 via email

@CHAMPIOM1
Copy link

CHAMPIOM1 commented Jul 22, 2022 via email

@Cope9560 Cope9560 changed the title 第19课 代码是不是有问题 第21课 代码是不是有问题 Jul 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants