如果文件已经存在,我需要在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) –