我想制作一个脚本,使目录(名称输入) ,并在刚刚创建的输入文件夹中创建第二个目录。Python创建用户输入的子目录
import os
import sys
user_input = raw_input("Enter name: ")
user_input1 = raw_input('Enter case: ')
path = user_input
if not os.path.exists(path):
os.makedirs(path)
path = user_input1
if not os.path.exists(user_input/user_input1):
os.makedirs(path)
我得到
if not os.path.exists(user_input/user_input1):
TypeError: unsupported operand type(s) for /: 'str' and 'str'
我在做什么错在这里?
我试着这样做:
if not os.path.exists('/user_input1/user_input'):
但是,这导致它使两个单独的目录没有子目录
你做平均'os.path.join(USER_INPUT,user_input1)'。你写的是用'user_input1'分割(字符串)'user_input'。 – dhke