小编Add*_*ddi的帖子

在不带前导0的文本字符串中查找float

我试图从像这样的文本字符串中捕获浮点数(使用Python 3):

.31 [0.25-0.37] m2 incr

如果我使用以下代码,这适用于格式为0.45的数字:

import re
re.findall("\d+.\d+", ".31 [0.25-0.37] m2 incr")
Run Code Online (Sandbox Code Playgroud)

但如果缺少null,如.31,则不会复制该数字.我尝试了一些变化,但没有成功; 任何人都能指出我正确的方向吗?

python regex floating-point

1
推荐指数
1
解决办法
92
查看次数

标签 统计

floating-point ×1

python ×1

regex ×1