AttributeError: 'User' object has no attribute
时间: 2023-08-04 07:04:21 浏览: 126
引用\[1\]:AttributeError: ResultSet object has no attribute 'text'. You're probably treating a list of elements like a single element. Did you call find_all() when you meant to call find()? 。 引用\[2\]: 今天在使用LTP,并进行添加词典时,却出现了AttributeError: ‘LTP‘ object has no attribute ‘init_dict‘的错误提示,具体如下图所示: 在经过了亲身的实践后,终于找到了解决问题的方案,最终将逐步的操作过程总结如下。希望能对遇到同样bug的同学有所帮助。 。 引用\[3\]:错误代码: import requests from bs4 import BeautifulSoup headers={'user-agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) ' \ 'AppleWebKit/537.36 (KHTML, like Gecko) ' 'Chrome/99.0.4844.51 Safari/537.36'} url="https://listado.mercadolibre.com.mx/hogar-muebles-jardin/seguridad-hogar/sistemas-monitoreo/camaras-seguridad/security-camera_NoIndex_True" res_news = requests.get(url, headers=headers) #实例化html bs=BeautifulSoup(res_news.text,'html.parser') # 获取数据 divs=bs.find_all('div',class_="ui-search-result__content-wrapper shops__result-content-wrapper") #print(divs) for div in divs: links=div.find('a').get('href') # print(links) res_news2=requests.get(url=links, headers=headers) # print(res_news2.text) #实例化html bs2 = BeautifulSoup(res_news2.text, 'html.parser') # print(bs2) # 获取数据 titles = bs2.find_all('h1',class_='ui-pdp-title') print(titles.text) 。 问题:AttributeError: 'User' object has no attribute
回答: AttributeError: 'User' object has no attribute是一个错误提示,意味着在代码中使用了一个名为'User'的对象,但该对象没有名为'attribute'的属性。这通常是因为代码中的某个地方出现了错误,可能是因为对象的命名错误或者对象没有被正确初始化。要解决这个问题,你需要检查代码中使用'User'对象的地方,并确保对象的命名正确,并且对象被正确地初始化。
#### 引用[.reference_title]
- *1* *3* [错误:AttributeError: ResultSet object has no attribute ‘text‘.](https://blog.csdn.net/weixin_61038883/article/details/128222176)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item]
- *2* [AttributeError: ‘LTP‘ object has no attribute ‘init_dict‘解决方案](https://blog.csdn.net/weixin_43178406/article/details/130220058)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item]
[ .reference_list ]
阅读全文