|||
引入shutil模块
import shutil
复制或移动到目的文件夹下面
shutil.copy('demo.txt','新的文件夹')
file1.txt 移动到 新的文件夹 下面
shutil.move('file1.txt','新的文件夹')
复制或移动到目的文件夹下面之后,重命名
shutil.copy('demo.txt','新的文件夹/new1.txt')
shutil.move('file2.txt','新的文件夹/new2.txt')
导入os模块
import os
删除 file1.txt
os.remove('file1.txt')
删除 文件夹1 下面的 file1.txt
os.remove('文件夹1/file1.txt')
删除 文件夹1
shutil.rmtree('文件夹1')
————————————————
版权声明:本文为CSDN博主「Asher117」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/Asher117/article/details/109083247
Archiver|手机版|科学网 ( 京ICP备07017567号-12 )
GMT+8, 2024-6-5 13:27
Powered by ScienceNet.cn
Copyright © 2007- 中国科学报社