1、基础
1、jupyter notebook安装第三方包:!pip install pyquery
超时问题:
pip install jieba –index https://pypi.mirrors.ustc.edu.cn/simple/
2、图表正常显示汉字:
from matplotlib import font_manager
my_font = font_manager.FontProperties(family='SimHei', size=15)
my_font1 = font_manager.FontProperties(family='SimHei', size=10)
fig,ax = plt.subplots(figsize=(8,6))
plt.bar(x,y)
plt.title("每个市辖区的烤匠店铺数量",fontproperties=my_font)
plt.ylabel("烤匠店铺数量",fontproperties=my_font1)
plt.show()
3、list
list.append()
if list:如果list不为空
将list转为DataFrame:
https://blog.csdn.net/senwen616/article/details/82662093
2、爬虫
1、html.status_code 200代表服务器正常响应 404代表页面未找到
2、res = requests.get(url,headers=headers) 向网站发起请求,并获取响应对象
doc=res.text
doc(“div.reviews-items > ul > li”).items() 返回节点的生成器generator object PyQuery.items
3、报错
1、报错 XXX is not callable时,是因为代码调用了一个不能被调用的变量或对象