Make Multiple Subdirectories In Python -


i doing kind of special code right here. making code create 1 - 10 directories called box1, box2... until 10. in these directories there other directories. , in these directories more subdirectories... . @ end, generate key. here have now:

import time import random import subprocess import os import os.path  liste = [] old = [] key = false numberofboxes = 5 files = -1 number = random.randint(1, 10)  def random_generator():     looper in range(1, numberofboxes):         rand = random.randint(1, 10)         liste.append(rand)   def calculate():     c = liste[0]     looper in range(1, c):         print(looper)         newpath = 'box' + str(looper)         if not os.path.isdir('./' +newpath+'/'):             os.mkdir('./' +newpath+'/')   def subdir_true():     files = -1     read = liste[0]     chance = random.randint(1, 2)     looper in range(1, read):         if chance == 1:             looper in range(1, read):                 exist = os.path.exists('box' + str(looper))                 if exist == true:                      newpath = 'box' + str(looper)                     old.append(newpath)                     files += 1                     oldf = old[files]                     number = random.randint(1, 10)                     looper in range(1, number):                         newpath = 'box' + str(looper)                         os.mkdir('./'+oldf+'/'+newpath+'/')   random_generator() calculate() subdir_true() 

how make subdirectories subdirectories using for looper in range()?

see docs os.makedirs()

recursive directory creation function. mkdir(), makes intermediate-level directories needed contain leaf directory. raises error exception if leaf directory exists or cannot created. default mode 0777 (octal). on systems, mode ignored. used, current umask value first masked out.


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -