目录创建函数

def mk_dir(mypath = 'd:\\turnover_rate\\'):
      '检查目录,没有则创建'
      os.chdir('d:\\')
      if not os.path.exists(mypath):
            os.mkdir(mypath)
      os.chdir(mypath)
      if not os.path.exists('data'):
            os.mkdir('data')
      if not os.path.exists('base'):
            os.mkdir('base')
      if not os.path.exists('sys'):
            os.mkdir('sys')
      if not os.path.exists(mypath +'sys\\path.xlsx'):
            wb = Workbook()
            ws = wb.active
            wb.save(mypath +'sys\\path.xlsx')
            wb.close()
      return mypath

猜你喜欢

转载自blog.csdn.net/lee2601/article/details/81084797