01 2023 档案
摘要:解决方法: requests.get(url_file, stream=True)在requests函数中增加stream=True参数,问题解决 爬虫运行时报:'Connection broken: IncompleteRead(1482 bytes read, 2614 more expecte
阅读全文
摘要:python3 获取request 302跳转后最终的URL 代码: import requests resp = requests.get(rtsp_url, timeout=(3, 7)) if len(resp.history) > 0: location_url = resp.history
阅读全文
摘要:import time import requests import requests.cookies # 格式化成2016-03-20 11:45:39形式 print(time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())) print(time
阅读全文
摘要:# 格式化成2016-03-20 11:45:39形式print (time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()))
阅读全文
摘要:Python的异常机制主要依赖 try、except、else、finally和raise五个关键字, 其中在try关键字后缩进的代码块简称try块,它里面放置的是可能引发异常的代码; 在except后对应的是异常类型和一个代码块,用于表明该except块处理这种类型的代码; 在多个except块之
阅读全文
摘要:##########################################################源代码中因为返回的是跳转url,所以写的是resp.text,本案中resp返回的是文件,所以直接返回resp.content原类型#在其他案例中,如果返回的是下载url,则应该写成r
阅读全文
摘要:首席引入依赖安装waitrss pip intsll waitress 然后在flask程序内引入依赖 使用server()函数代替app.run()函数 启动时,直接python xxx.py即可 from waitress import serve from flask import Flask
阅读全文
摘要:在pycharm终端, pip freeze > requirements.txt
阅读全文