属性错误:'list' 对象没有 'text' 属性 - python

2024-09-27 07:28:21 发布

您现在位置:Python中文网/ 问答频道 /正文

在我的代码中。文本在第三行运行良好,但是

AttributeError: 'list' object has no attribute 'text'`

最后一行出错。两者都一样,但问题是什么?在

for elem6 in doc.findall('.//medicationsInfo/entryInfo'):   
       drugcodeSystem.append(elem6.find('productCode/codeSystem'))
       drugname.append(elem6.find('productCode/displayName').text)  
       routecode.append(elem6.find('routeCode/code'))   
       routecodeSystem.append(elem6.find('routeCode/codeSystem'))   
       drugname1.append(elem6.find('productCode/codeSystemName').text)

Tags: no代码text文本objectattributefindlist

热门问题