pycharm—项目文件下的子目录的删除

Posted 夜猫心理委员

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了pycharm—项目文件下的子目录的删除相关的知识,希望对你有一定的参考价值。

 

删除前:

 

删除后:

import os
CUR_PATH = r\'C:\\Users\\shenping\\PycharmProjects\\Shenping_TEST\\day_5\\Testfolder\'
def del_file(path):
    ls = os.listdir(path)
    for i in ls:
        c_path = os.path.join(path, i)
        if os.path.isdir(c_path):
            del_file(c_path)
        else:
            os.remove(c_path)

del_file(CUR_PATH)

  

 

以上是关于pycharm—项目文件下的子目录的删除的主要内容,如果未能解决你的问题,请参考以下文章