gpt4 book ai didi

python - Beautiful Soup 标签有冒号。需要提取温度值。

转载 作者:太空宇宙 更新时间:2023-11-03 13:18:56 25 4
gpt4 key购买 nike

<分区>

我想输出温度 -> 34,但标签 (yweather:condition) 中的冒号导致语法错误

例如,这是我的 xml 文件的示例

<pubDate ...> </pubDate> <yweather:condition  text="Cloudy"  code="26"  temp="34"  date="Fri, 20 Dec 2013 3:20 pm PST" /> <xml text>

到目前为止我的代码:

soup = BeautifulSoup(myString)
temp = soup.yweather:condition['temp']
print temp

结果 - 语法无效

我试过下面的代码,但不确定如何从这里获取临时值。

temp = soup.find('yweather:condition')

提前致谢,乔恩

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com