复制文件
~~~
import shutil
shutil.copyfile('test1.txt', 'test1.txt.copy')
~~~
案例:
~~~
# 在zip文件夹内新增文件
new_path_file = 'static\zip\z_ResRoot.zip'
new_zipfile = 'z_ResRoot/1/res_list_all.txt'
zipFile = zipfile.ZipFile(new_path_file, 'a')
zipFile.writestr(new_zipfile, 'Add something \n')
# 解压
copy_path = 'static/zip'
for file in zipFile.namelist():
zipFile.extract(file, copy_path)
zipFile.close()
# 移动新增文件到目标文件
old_zipfile = 'static/zip/z_ResRoot/res_list_all.txt'
new_zipfile = 'static/zip/z_ResRoot/1/res_list_all.txt'
shutil.move(new_zipfile, old_zipfile)
~~~