python关于文件夹的一些操作

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/MHeartWGO/article/details/87301061

def setDir():
    if  not os.path.exists('./test'):
        os.makedirs('./test')
    else:
        shutil.rmtree('./test')
        os.mkdir('./test')

当没有文件夹时,创建文件夹;

有文件夹时,删除现有文件夹,创建一个同名文件夹。。。

emmmmm。。。就是这样。

猜你喜欢

转载自blog.csdn.net/MHeartWGO/article/details/87301061