[英]How do I copy a large file in chunks from a source file to a destination file using python?
The file can be say 20GB.该文件可以说是 20GB。 The traditional approach of importing,reading a file and then writing to another file is not feasible.
传统的导入、读取文件然后写入另一个文件的方法是不可行的。
For file-like objects (buffers, request bodies, etc.) you can use shutil.copyfileobj对于类文件对象(缓冲区、请求主体等),您可以使用shutil.copyfileobj
with open('path/to/dest.file', 'wb') as dst:
shutil.copyfileobj(source_file_like_object, dst)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.