-1
我想在某個目錄內創建一個文件夾,但我想從用戶輸入使用rawinput函數。使用rawinput創建文件夾及其用戶名
if not os.path.exists(directory):
os.makedirs(directory)
我想在某個目錄內創建一個文件夾,但我想從用戶輸入使用rawinput函數。使用rawinput創建文件夾及其用戶名
if not os.path.exists(directory):
os.makedirs(directory)
是這樣的?
parentdir = '/home/waldo/foobar/'
subdir = raw_input('please name subdirectory: ')
dir = os.path.join(parentdir, subdir)
if not os.path.exists(dir):
os.makedirs(dir)
是的,喜歡,我以後要使用這個新的目錄,那麼,如何實現一個「/ home /沃爾多/ foobar的/ DIR」 – Bolly
在我的例子中的第三行中,變量'dir'會分配父目錄加用戶輸入的子目錄的名稱。我認爲這是你想要的,對吧? –
是的,謝謝我混淆了。 – Bolly