这是 Google Colab 中的错误还是我做错了什么?

问题描述 投票:0回答:0

这说 input 是 ET 的一个对象,但 input 不是一个函数吗?此外,我从来没有制作过一个名为 input 的对象,所以为什么会这样?

我应该怎么做才能解决这个问题?

代码:

import xml.etree.ElementTree as ET
import urllib.request,urllib.parse,urllib.error

u=input('Enter Location:')
print("Retirieving ",u)

uh = urllib.request.urlopen(u)

data = uh.read()
print("Retrieved",len(data),"characters")

tree=ET.fromstring(data)

sum=0
c=0

counts = tree.findall('.//count')

for val in counts:
  sum+=int(val.text)
  c+=1

print("Count:",c)
print("Sum:",sum)

错误信息:

TypeError                                 Traceback (most recent call last)
<ipython-input-19-af23c96a0ad5> in <module>
      2 import urllib.request,urllib.parse,urllib.error
      3 
----> 4 u=input('Enter Location:')
      5 print("Retirieving ",u)
      6 

TypeError: 'xml.etree.ElementTree.Element' object is not callable
python xml elementtree
© www.soinside.com 2019 - 2024. All rights reserved.