0
我在這裏做了一種特殊的代碼。我正在創建一個代碼,它將創建1-10個目錄,稱爲box1,box2 ...直到10.在這些目錄中會有其他目錄。在這些目錄中有更多的子目錄......。最後,它會生成一個密鑰。以下是我對現在:在Python中製作多個子目錄
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():
for looper in range(1, numberOfBoxes):
rand = random.randint(1, 10)
liste.append(rand)
def calculate():
c = liste[0]
for 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)
for looper in range(1, read):
if chance == 1:
for 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)
for looper in range(1, number):
newpath = 'Box' + str(looper)
os.mkdir('./'+oldF+'/'+newpath+'/')
random_generator()
calculate()
subdir_true()
我如何子目錄到使用for looper in range()
子目錄?
好極了。那麼你的問題是什麼? – CoryKramer