2011-02-23 45 views
1
def creating_folder_for_csv_files(cwd): 
    try: 
     os.makedirs(cwd+'\\migration_data\\trade') 
    except os.error, e: 
     print "Could not create the destination folder for CSV files" 
    # end of first try/except block 

    try: 
     os.makedirs(cwd+'\\migration_data\\voucher') 
    except os.error, e: 
     print "Could not create the destination folder for CSV files" 

在我的代碼中,第一個try/except塊的作品,但第二個沒有。有什麼問題?多次嘗試/除了在一個單一的功能不起作用

+6

請更具體地說明你的意思是'不'[work]?'預期的行爲是什麼,你看到的行爲是什麼? – phooji 2011-02-23 06:50:46

+0

當你說它不起作用時,你是什麼意思?它不創建目錄?它會拋出異常?都不是? – Gabe 2011-02-23 06:50:55

+1

值得一提的是,使用[os.path.join](http://docs.python.org/library/os.path.html#os.path.join)來加入一個或多個路徑組件。 – Paolo 2011-03-13 14:29:16

回答

0

voucher可能已經存在。