美文网首页
python os,shutil基本使用

python os,shutil基本使用

作者: slytherinwyne | 来源:发表于2020-01-17 18:41 被阅读0次

import os

if not os.path.exists(Dir):

os.mkdir(Dir)

os.remove(path)

def data_path(filename):

       return os.path.join(os.path.dirname(__file__), "%s" % filename)

递归的删除result_dir下所有文件

import shutil

if os.path.exists(result_dir):

          shutil.rmtree(result_dir)

os.mkdir(result_dir)

相关文章

网友评论

      本文标题:python os,shutil基本使用

      本文链接:https://www.haomeiwen.com/subject/lbhhzctx.html