与浮点数匹配的Python正则表达式

2024-05-14 16:39:27 发布

您现在位置:Python中文网/ 问答频道 /正文

Possible Duplicate:
How to detect a floating point number using a regular expression

如何编写与浮点数的字符串表示形式匹配的Python正则表达式?

表达式应与float构造函数接受的任何字符串匹配,如float('3.5')。因此,表达式应该匹配'0.''.0',而不是'.'

不需要匹配无穷大和NaN的字符串表示。


Tags: to字符串number表达式floathowpointusing

热门问题