![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
python
倔强的烤马铃薯
互联网从事人员,工作为前端开发,擅长pc端,小程序,APP开发。
展开
-
Python爬虫报错<Response [200]>
初学python,爬数据的时候报错<Response [200]>import requestsurl='https://club.jd.com/comment/productPageComments.action?callback=fetchJSON_comment98&productId=8452203&score=0&sortType=5&page=0&pageSize=10&isShadowSku=0&fold=1'det=r原创 2021-04-15 09:15:18 · 5544 阅读 · 1 评论 -
python获取列表数字的下标
因为input输入的是字符型的,所以要转换一下,不然会报错list= [8, 23, 45, 12, 78]int =0while int!=1: str = input('输入数字获取序号:') if float(str) in list: print(list.index(float(str))) print('数字',str,'的序号是',list.index(float(str))) int = 1 else:原创 2021-03-02 09:57:07 · 891 阅读 · 0 评论 -
Python报错 :UnboundLocalError: local variable ‘num‘ referenced before assignment
1.python局部作用域引用错误。因为 test 函数中的 num使用的是局部,未定义,所以无法进行修改num = 10 --全局定义def test(): num = num+ 1 --局部未定义 print(anum)test()2.改为num = 10 --全局定义def test(): num=1 --局部定义num num = num+ 1 print(num)print(test()) ---2print(num原创 2021-02-25 11:14:57 · 873 阅读 · 0 评论