1
aitaii Jun 17, 2016
|
2
lxy Jun 17, 2016
报错信息写得很清楚了,一步步往上看,你的 proxy 数据类型不对。
|
3
ming2050 Jun 17, 2016 via Android
传入的应该是 dict 而不是 str
|
4
Kisesy Jun 17, 2016
看看你注释的地方
|
5
sparkssssssss OP 我传入的是 dict 啊,所以我才比较纳闷
[root@localhost sh]# python httpreq.py {'http':'http://116.226.98.54:8118'} 这个是我打印出来的 proxy True 'str' object has no attribute 'get' None |
6
sparkssssssss OP |
7
Kisesy Jun 17, 2016 你确定这是 dict ?
return "{\'http\'"+":"+"\'http://"+ip+"\'}" 这样写不好吗 def rewrite(ip): return {'http':'http://' + ip} |
8
sparkssssssss OP 我那个 rewrite 返回的是 str,不是 dict,所以 proxies 传入的类型错误了,我刚看了下 p 的类型是 str,不是 dict,多谢各位.
|
9
sparkssssssss OP @Kisesy 是的,我那样返回的是 str,刚学 python,多谢指点.
|
10
SuperFashi Jun 17, 2016 via Android
@coolloves 虽然你是传了个 str 回去,不过 eval 一发即可
|
11
siteshen Jun 17, 2016
@SuperFashi 别带坏初学者!!
|
12
SlipStupig Jun 19, 2016
@SuperFashi eval 是方便,但是不安全,能少用就少用
|