lrgstPlace = features[0]
strLrgstPlace = str(lrgstPlace)
longtide = re.match("r(lat=)([\-\d\.]*)",strLrgstPlace)
print (longtide)
这就是我的功能列表的样子
Feature(place='28km S of Cliza, Bolivia', long=-65.8913, lat=-17.8571, depth=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放在引号之外:
r"(lat=)([\-\d\.]*)"
您的原始表达式工作正常,如果只想提取lat数,我们可能需要稍微修改它:
其中
DEMO([0-9\.\-]+)
将捕获我们想要的lat,我们将其包装为两个非捕获组:测试
相关问题 更多 >
编程相关推荐