1、代码示例 def file_copy(source_file, target_file): with open(source_file, "rb") as source: with open(target_file, "wb") as target: data = source.read(512) while data: target.write(data) data = source.read(512) 2、测试效果 最终文件桌面也生成了,文件内容也成功写过去了。 其他文件操作参考这里