First, the folder creation code is
import os
def folder(dir):
try:
if not os.path.exists(dir):
os.makedirs(dir)
except OSError:
print('error: up.' + dir)
folder('./1/2/3/4/5/6/7/8/9/10')
This creates folder 2 in folder 1, folder 3 in folder 2, and folder 10 in folder 9.
I want to make a repeat sentence for sentence or while, so how should I put it in?
python
import os
path = os.getcwd()
for i in range(0, 3):
path = os.path.join(path, str(i))
print(f'we will mkdir {path}')
os.mkdir(path)
© 2024 OneMinuteCode. All rights reserved.