from urllib.request import urlopen import hashlib #入境限制的常见问题 url1 = "https://china.diplo.de/blob/2368124/aab5f9c2d40b4a8884352295f99004ac/pdf-faq-covid-ch2018-data.pdf" #入境提示 url2 = "https://china.diplo.de/blob/2374460/115ac4903c0da03528e9c75206ac44f7/pdf-einreisebeschraenkungen--chinesisch--englisch--deutsch--data.pdf" def GetFile(url): fname = url.split("/")[-1] with urlopen(url) as fp: with open("D:\\eclipse-workspace\\PyDevAllTest\Embassy\\a\\" + fname,'wb') as fp1: file = fp.read() file_md5= hashlib.md5(file).hexdigest() print(file_md5) fp1.write(file) GetFile(url1) GetFile(url2)