我要做的就是导入一个xml并把它变成一个美丽的汤对象 .
r = requests.get("http://svn.testing.com:8080/env.xml", auth=creds)
print r.text #note.. this prints the xml and everything looks correct so no problem there.
clean_xml = BeautifulSoup(open('r.text', 'r'), 'xml')
当我运行这个时,我得到:
IOError: [Errno 2] No such file or directory: 'r.text'
print r.text打印出如预期的那样 .
在这个项目的早期,我正在导入一个美味汤的本地文件,现在我从一个网址导入,所以我不知道这是否与此问题有关 .
1 回答
没有这样的 file 是一个明显的错误 .
您正在尝试使用
open('r.text', 'r')
打开名为"r.text"的文件尝试实际使用
r.text
变量