shutil
模块的意义是什么,以及这两种方法之间有什么区别:file_location = f"files/{uploaded_file.filename}"
with open(file_location, "wb+") as file_object:
file_object.write(uploaded_file.file.read())
并且这个:
import shutil
file_location = f"files/{uploaded_file.filename}"
with open(file_location, "wb+") as file_object:
shutil.copyfileobj(uploaded_file.file, file_object)
在我的编程经验中,我多次遇到了
shutil
模块,但仍然无法确定它相对于read()
和write()
方法的优势。