84669 Lernen von Personen
152542 Lernen von Personen
20005 Lernen von Personen
5487 Lernen von Personen
7821 Lernen von Personen
359900 Lernen von Personen
3350 Lernen von Personen
180660 Lernen von Personen
48569 Lernen von Personen
18603 Lernen von Personen
40936 Lernen von Personen
1549 Lernen von Personen
1183 Lernen von Personen
32909 Lernen von Personen
怎么使用Python删除当前目录下除当前脚本以外的文件和文件夹?
怎么使用Python删除当前目录下除当前脚本以外的文件和文件夹?-PHP中文网问答-怎么使用Python删除当前目录下除当前脚本以外的文件和文件夹?-PHP中文网问答
围观一下哦,学习一下。
用一个实例说明Python实现删除当前目录下除当前脚本以外的文件和文件夹:
import os,sys import shutil cur_file = os.path.basename(sys.argv[0]) dir_content = [x for x in os.listdir(".") if x != cur_file] for f in dir_content: if os.path.isdir(f): shutil.rmtree(f) else: os.remove(f)
怎么使用Python删除当前目录下除当前脚本以外的文件和文件夹?-PHP中文网问答-怎么使用Python删除当前目录下除当前脚本以外的文件和文件夹?-PHP中文网问答
围观一下哦,学习一下。
用一个实例说明Python实现删除当前目录下除当前脚本以外的文件和文件夹: