python操作windows目录

参考:
https://blog.51cto.com/u_16213333/7440207
https://www.docdocx.com/wendang/qitafanwen/274964.html
https://blog.51cto.com/u_16213340/7400929(路径存到mysql斜杠消失)

判断目录是否存在后创建目录

   while os.path.exists(local_dir):
       local_dir = local_dir + ranstr(8)

   try:
       os.mkdir(local_dir)
   except Exception as e:
       print ('目录创建失败:' + str(e))

你可能感兴趣的:(python,windows,目录)