我有这样的代码:
import requests
import xmltodict
Locations = ['http://129.94.5.93:49154/setup.xml', 'http://129.94.5.92:49154/setup.xml', 'http://129.94.5.93:49154/setup.xml', 'http://129.94.5.92:49154/setup.xml', 'http://129.94.5.95:80/description.xml']
for item in Locations:
r = requests.get(item)
reply = xmltodict.parse(r.text)
这给了我以下错误:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "ssdpxml.py", line 57, in <module>
r = requests.get(item)
AttributeError: 'str' object has no attribute 'get'
但是当我这样做时它会起作用:
r=requests.get('http://129.94.5.95:80/description.xml')
为什么我会收到上述错误?