我在学习这个帖子里面的源代码时运行报错,详细如下:
- i =0
- type='true'
- url='http://www.lagou.com/jobs/positionAjax.json?px=default&first='+type+'&kd='+keywordindex+'&pn='+str(i+1)
- with request.urlopen(url) as f:
- data=f.read()
- urlcount=int(json.loads(str(data,encoding='utf-8',errors='ignore'))["content"]["totalPageCount"])
- print('本次搜索页面共计%d'%urlcount)
顺便再请教两个问题:
程序中的str(i+1)用什么特别的作用吗?str(data,encoding='utf-8',errors='ignore')这的str函数允许有后面两个参数吗?我这运行也报错啊,说最多一个参数。
先谢谢各位高手啦,俺是小白!