[Record it] Error reporting AttributeError: 'NoneType' object has no attribute 'text'
question
The following error occurs when running the xml to txt file
The reason is that some of the different xml files may still exist <difficult>0</difficult>
, and some files do not. This problem cannot be solved in the original code.
The original code is as follows:
Solution
Change it to the following
#difficult = obj.find('difficult').text
if obj.find('difficult'):
difficult = int(obj.find('difficult'.text))
else:
difficult = 0
Subsequent runs succeed.
Source: Log Error: AttributeError: 'NoneType' object has no attribute 'text'