如果文件已經存在,我需要在python中創建一個跳過函數,跳過我的下載代碼。如果文件已經存在,Python跳過一個函數
怎樣的功能應該工作: (如果存在該文件無需運行這段代碼,就跳到下一個代碼 如果它不存在,然後運行該代碼,然後運行下面的代碼。)
Filecheck = os.path.join(OUTPUT_FOLDER,"test"+version+"exe")
print Filecheck
if not os.path.exists(Filecheck):
base_url = urlJoin(LINK, + version + "_multi.exe")
print base_url
filename2 = "%s_%s_.exe" % (software.capitalize(),version)
original_filename = os.path.join(OUTPUT_FOLDER, filename2)
if writeFile(original_filename, httpRequestFile(base_url), "wb") and os.path.exists(original_filename):
print "Download done"
你或許可以使用答案[我如何檢查文件是否存在使用Python?](http://stackoverflow.com/questions/82831/how-do-i-check-if-a-file-exists-using-python) –