This error occurs when you try to access the 'text' attribute of a variable that is of type 'NoneType'. In this case, the variable 'hero.select_one(".ename")' is returning 'None' instead of an object with the 'text' attribute.

To fix this error, you need to check if the variable 'hero.select_one(".ename")' is None before accessing its 'text' attribute. For example:

name_element = hero.select_one(".ename")
if name_element is not None:
    name = name_element.text
else:
    name = "Unknown"

This code checks if the 'name_element' variable is not None before accessing its 'text' attribute. If it is None, it sets the 'name' variable to "Unknown"

Traceback most recent call last File Epythonprojectpython1py line 27 in module name = heroselect_oneenametextAttributeError NoneType object has no attribute text

原文地址: https://www.cveoy.top/t/topic/hnwO 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录