1 回答

TA貢獻1796條經驗 獲得超7個贊
雖然wget沒有提到,你可以自己改變它。使用os.path.basename()獲取文件名,并檢查它是否存在。像這樣:
import wget
import os
urls = ['https://www.iedb.org/downloader.php?file_name=doc/epitope_full_v3.zip',
'https://www.iedb.org/downloader.php?file_name=doc/tcell_full_v3.zip',
'https://www.iedb.org/downloader.php?file_name=doc/bcell_full_v3.zip',
'https://www.iedb.org/downloader.php?file_name=doc/mhc_ligand_full_single_file.zip']
path = '/home/david/data/files/zip_files'
for url in urls:
filename = path + '/' + os.path.basename(url) # get the full path of the file
if os.path.exists(filename):
os.remove(filename) # if exist, remove it directly
wget.download(url, out=filename) # download it to the specific path.
添加回答
舉報