2017-01-31 32 views

回答

1

是這樣的?

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) 
+0

是的,喜歡,我以後要使用這個新的目錄,那麼,如何實現一個「/ home /沃爾多/ foobar的/ DIR」 – Bolly

+0

在我的例子中的第三行中,變量'dir'會分配父目錄加用戶輸入的子目錄的名稱。我認爲這是你想要的,對吧? –

+0

是的,謝謝我混淆了。 – Bolly

相關問題