Python3-问题整理
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


Python3-问题整理的更多相关文章
- python3 基础整理
基础语法 1.python中区分大小写 2.查看关键字用 import keyword print (keyword.kwlist) 3.注释 # 单行注释,多行注释的快捷键是ctr+/,取消注释的 ...
- python3.7 内置函数整理
#!/usr/bin/env python __author__ = "lrtao2010" #python3.7 内置函数整理 #abs(x) #返回数字的绝对值. 参数可以是整 ...
- python3.7内置函数整理笔记
#python3.7 内置函数整理 #abs(x) #返回数字的绝对值. 参数可以是整数或浮点数. 如果参数是复数,则返回其大小 # print(abs(1)) # print(abs(-1)) # ...
- 整理了最全的Python3数据类型转换方法,可以收藏当手册用
本文基于python3.8版本,总结了各种数据类型直接的转换规则和方法.算是比较全了,可以收藏当手册来查. 概述 数据类型转换,指的是通过某种方法,将一个数据由原来的类型转换为另外一个类型.比如,我们 ...
- 整理一下pywinauto 的sendeys(py2.7)换成python3.6用PyUserInput
没办法入门学的是py3.6所以有些只支持2.7的库保好放弃了 senkeys (2.7)==>pyuserinput (3.6) ================================ ...
- Python3的编码整理总结
python3在内存中是用unicode编码方式存储的,所以不能直接储存和传输,要转化为其他编码进行储存和传输. 字符串通过编码转换成字节码,字节码通过解码成为字符串 encode:str --> ...
- 字符编码 + python2和python3的编码区别(day08整理)
目录 昨日回顾 二十三.元组内置方法 二十四.散列表 二十五.字典内置方法 二十六.集合内置方法 二十七.深浅拷贝 拷贝 浅拷贝 深拷贝 今日内容 二十八.字符编码 1.文本编辑器存储信息的过程 2. ...
- python2与python3的区别齐全【整理】
本文链接:https://blog.csdn.net/pangzhaowen/article/details/80650478 展开 一.核心类差异1. Python3 对 Unicode 字符的原生 ...
- Python3整理文件
晚上打算把播放器下载下来的音乐拷贝到mp3里边,但是它是如下形式存放的,相当头痛…… 作为程序员,想到使用python来遍历这个目录,并将有大于限制的音乐文件拷贝到指定目录,相关实现代码如下: # a ...
- 廖雪峰老师Python3教程练习整理
1.定义一个函数quadratic(a, b, c),接收3个参数,返回一元二次方程:ax2 + bx + c = 0的两个解 # -*- coding: utf-8 -*-import mathde ...
随机推荐
- Codeforces 396C (DFS序+线段树)
题面 传送门 题目大意: 给定一棵树,每个点都有权值,边的长度均为1,有两种操作 操作1:将节点u的值增加x,并且对于u的子树中的任意一个点v,将它的值增加x-dist(u,v)*k, dist(u, ...
- Acwing.835. Trie字符串统计(模板)
维护一个字符串集合,支持两种操作: “I x”向集合中插入一个字符串x: “Q x”询问一个字符串在集合中出现了多少次. 共有N个操作,输入的字符串总长度不超过 105105,字符串仅包含小写英文字母 ...
- TypeScript从入门到Vue项目迁移
1. 前言 ES6的普及,大大简化了JavaScript的表达方式 大型项目中,js没有类型检查.表达方式灵活,多人协作代码调试和维护成本高 2. 定义 TypeScript 是 JavaScript ...
- webpack之给目录起别名
1. 配置文件目录: build>webpack.base.config.js: resolve: { alias: { '@': resolve('src'), //照猫画虎 'styles' ...
- R语言——ggplot2补充知识点
案例 ggplot(head(age_data,10),aes(x=reorder(Country,age_median),y=age_median))+ geom_bar(aes(fill=Coun ...
- python内存分析
安装 首先安装memory_profiler和psutil pip install memory_profiler pip install psutil 在需要分析的函数前面添加装饰器@profile ...
- python基础--2 字符串
整型 int python3里,不管数字多大都是int类型 python2里面有长整型long 将整型字符串转换为数字 # a='123' # print(type(a),a) # b=int(a) ...
- shell 操作mysql
1.连接 #!/bin/bash user="root" password="XXXXXX" sql = `mysql -u>/dev/null use ...
- ThinkPhp view 路径用到的常量 __STATIC__ __JS__ __CSS__等
https://www.edoou.com/articles/1556848583530922 ThinkPHP5.1 里面__PUBLIC__无法生效的问题 在用PHP模板的时候需要引用外部的样式文 ...
- 【leetcode】1029. Two City Scheduling
题目如下: There are 2N people a company is planning to interview. The cost of flying the i-th person to ...