close

 

2017 06 03

當使用 ftp.nlst 去列出在Server上的檔案,但是當程式在Server上找不到任何符合條件的檔案時
程式會中止且產生下面的錯誤訊息

ftplib.error_perm: 550 No files found.

 

我們可使用下面的程式片段去解決這個空目錄的問題

try:
    ls = ftp.nlst('D1*.txt')
except ftplib.error_perm as e:
    print "Directory is empty : "+str(e)
    exit(1)

 

回主目錄

arrow
arrow

    stanley 發表在 痞客邦 留言(0) 人氣()