2024-05-14 16:39:27 发布
网友
Possible Duplicate:How to detect a floating point number using a regular expression
如何编写与浮点数的字符串表示形式匹配的Python正则表达式?
表达式应与float构造函数接受的任何字符串匹配,如float('3.5')。因此,表达式应该匹配'0.'和'.0',而不是'.'
float
float('3.5')
'0.'
'.0'
'.'
不需要匹配无穷大和NaN的字符串表示。
r'[+-]?(\d+(\.\d*)?|\.\d+)([eE][+-]?\d+)?'
相关问题 更多 >
编程相关推荐