import urllib.request as r
import re
url=‘http://api.openweathermap.org/data/2.5/weather?q=hebi&mode=json&units=metric&lang=zh_cn&APPID=6a67ed641c0fda8b69715c43518b6996’
data=r.urlopen(url).read().decode(‘utf-8’)
ls1=re.compile(’“description”:"(.?)"’).findall(data) [‘晴’]
ls2=re.compile(’“temp”?.?),’).findall(data) [‘23.45’]
python正则爬天气
最新推荐文章于 2024-03-24 12:04:48 发布