python使用requests库下载文件
import os import requests def downfile(url): try: url=url.split("@")[0].split("?")[0] urlfile=url.split("/")[-1] print(urlfile) except Exception as e: print("地址不正确") data= requests.get(url); if(data.status_code==200): with open(urlfile,"wb") as f: f.write(data.content) else: print("404错误") if __name__ == '__main__': downfile("http://xb6.cn/tools/espy_cn/espy_CN.rar") pass