I';我在使用靓汤寻找时遇到问题<;名称></名称>;在xml中
我正在尝试使用beautifulsoup.name获取漂亮的汤返回文本。但它只是给了我一个漂亮的汤对象的[文档]。关于如何使用Beautiful Soup返回XML文件中的文本,有什么建议吗I';我在使用靓汤寻找时遇到问题<;名称></名称>;在xml中,xml,beautifulsoup,Xml,Beautifulsoup,我正在尝试使用beautifulsoup.name获取漂亮的汤返回文本。但它只是给了我一个漂亮的汤对象的[文档]。关于如何使用Beautiful Soup返回XML文件中的文本,有什么建议吗 import BeautifulSoup as bsoup f = open(file) soup = bsoup(f) f.close() f = soup.name This code will return [document] But I'm looking to for a functio
import BeautifulSoup as bsoup
f = open(file)
soup = bsoup(f)
f.close()
f = soup.name
This code will return [document]
But I'm looking to for a function in beautiful soup to return:
<name>car</name>
将美化组导入为b组
f=打开(文件)
汤=B组(f)
f、 关闭()
f=汤名
此代码将返回[文档]
但我希望在beautiful soup中有一个函数可以返回:
汽车
根据《美丽的汤》第4章
我明白了
你想要
import BeautifulSoup as bsoup
f = open(file)
soup = BeautifulSoup(f)
f.close()`
print(soup.find('name'))
用于打印
car
或print(soup.find('name').name)
用于打印car
添加了一些代码。我对编码有点陌生,所以我使用的一些术语可能含糊不清或笨拙。请随时要求更多的澄清。