Python3-问题整理
2024-09-25 15:46:58
TypeError: a bytes-like object is required, not 'str'
json.decoder.JSONDecodeError: Extra data
json文件太大,改为单行读取: with open("a", "r+") as f:
data = json.load(f) 改为: with open("a.json", "r+") as f:
data = f.readline()
UnicodeEncodeError: 'gbk' codec can't encode character u'\xe7' in position
将 print(res.txt) 改成 print(res.text).encode('gbk','ignore')
Https相关
requests发送HTTPS
前提:verify=False
报错:InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
解决:
import urllib3
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) 多线程 - connectionpool.py https请求 InsecureRequestWarning
解决:注释掉connectionpool.py的845-851行
IDE相关
Pycharm
全局查询关键字
按快捷键Ctrl + Shift + F或从从菜单Edit-》Find-》Find in Path进入全局查找界面
爬虫相关
Max retries exceeded with url
.requests.adapters.DEFAULT_RETRIES =
.s = requests.session()
s.keep_alive = False
Pycharm
File size exceeds configured limit 2.5M. Code insight features not available
help -》Edit custom properities -》输入 idea.max.intellisense.filesize=
字节/字符转换问题
TypeError: a bytes-like object is required, not ‘str’
str -》 encode()-》bytes
bytes -》decode() -》str
共存
python3-m pip install --upgrade pip --force-reinstall
python2-m pip install --upgrade pip --force-reinstall
netaddr
用途
ip地址管理
安装
pip3 install netaddr
模块 - Queue
用途
队列 使用
from queue import Queue
包安装报错
Crypto.Cipher
最新文章
- Xamarin教程索引页
- MVC+UnitOfWork+Repository+EF 之我见
- python操作TexturePacker批量打包资源plist png
- redis实现有序的消息队列
- POJ 1840 Eqs 暴力
- FE—— Code First 初体验 01(转)
- zabbix3.0.3 设置邮件报警
- 第一个java程序
- Ceph对象存储网关中的索引工作原理<;转>;
- SDP
- C#常用8种排序算法实现以及原理简介
- [flask实践] 解决qq邮箱/mysql的相关配置问题
- chrome console的使用 : 异常和错误的处理 – Break易站
- pandas小记:pandas基本设置
- ionic3使用cordova创建自定义插件
- java 日志框架
- 自学Linux Shell17.1-正则表达式
- 启明星请假系统appform:流程在线帮助
- Instagram/IGListKit 实践谈(UICollectionView框架)
- DCOS :私有云的物理基础架构管理引擎