zoukankan      html  css  js  c++  java
  • Python—创建目录

    import os

      os.mrkdir("D:\demo")                              #创建目录   mrkdir 无法传创建多级目录

      def mrkdir(path):                                      #创建递归函数 创建多级目录

      if not os.path.exists("D:\demo\test\python"):                  #判断路径是否存在

        os.mrkdir("D:\demo\test\python")

      else

        print("你创建的目录已经存在")

      def mrkdir(path):                                      #创建递归函数 创建多级目录

      if not os.path.isdir(path):                  #判断路径是否存在

        mrkdir(os.path.split(path)[0])

      else

        return

      os.mrkdir(path)

      mrkdir("D:\demo\test\python")

    #第二种创建多级目录

     os.makedirs("D:\demo\test\python")

  • 相关阅读:
    HUST-1350 Trie
    hihocoder-第六十一周 Combination Lock
    hihocoder-1196 : 高斯消元·二
    hihocoder-1195 : 高斯消元·一
    SPOJ
    HDU-5074
    UVALive
    POJ-2195
    UVALive
    POJ-1556
  • 原文地址:https://www.cnblogs.com/kzxiaotan/p/10520261.html
Copyright © 2011-2022 走看看