我在Stackoverflow很新,剛剛開始學習使用Python 3.3進行編程。我只是想向您展示我的代碼,並提供以下問題。從其他跳轉到函數的開始
整個腳本將被用來將我的博客的副本從ftp服務器複製到本地硬盤。
我想檢查一個激勵名稱的文件夾是否已經存在。如果是,我想等待60秒,然後重複。 60秒,因爲在此之後,我排除了我遇到同樣的問題。
我知道你會問自己爲什麼會這傢伙讓他的博客的多個副本在一分鐘內..的一點是,我要學習如何檢查,我可以運行在這些情況下。
這是我試過,但它不工作:
def create_backup_folder(ftp, destination_directory):
temp = time.localtime()
current_datetime = "{}-{}-{}_{}-{}".format(temp.tm_year, temp.tm_mon, temp.tm_mday, temp.tm_hour, temp.tm_min)
if not os.path.exists(destination_directory + 'bak_' + current_datetime):
os.mkdir(destination_directory + 'bak_' + current_datetime, 0o777)
print("Backup folder successfully created!")
else:
print("Folder already exists with the current date_time_stamp. Wait 60 seconds...")
time.sleep(60)
#create_backup_folder(ftp, destination_directory)
newDir = destination_directory + 'bak_' + current_datetime
download_directory(ftp, newDir)
的註釋掉的行給我一個錯誤:
AttributeError: 'NoneType' object has no attribute 'sendall'
我會很感激您的答覆!非常感謝!
有中'sendall'沒有打電話給你碼;也許錯誤在別處。 – nneonneo 2014-09-24 21:37:03