【发布时间】:2026-02-01 02:05:01
【问题描述】:
lrgstPlace = features[0]
strLrgstPlace = str(lrgstPlace)
longtide = re.match("r(lat=)([\-\d\.]*)",strLrgstPlace)
print (longtide)
这就是我的功能列表的样子
特征(地点='玻利维亚克利扎南 28 公里',长=-65.8913,纬度=-17.8571,深度=358.34,mag=6.3) Feature(place='12km SSE of Volcano, Hawaii', long=-155.2005, lat=19.3258333, depth=6.97, mag=5.54)
为什么正则表达式不能匹配任何东西?结果它只是给我“无”。
【问题讨论】:
-
将
r移出正则表达式... -
您可能也不想捕获“lat”,而只想捕获后面的数字:r"lat=([\-\d\.]*)"
-
您可能还需要
re.search而不是re.match。
标签: python regex python-3.x regex-lookarounds regex-group