我有一个我认为是数字的值,但是我用来确认该值是数字的RegEx失败了。
我不确定这是值的错误还是正则表达式的错误,因为这个正则表达式在过去的情况下对我有用。
regnumber = re.compile(r"(\d),(\d) | (\d)")
print("final weight:", weight)
if regnumber.search(weight):
print("weight = an int")
else:
print("weight does not = int")
这段代码产生:
final weight: 7088
weight does not = int
有人能给我解释一下为什么我的RegEx失败了或者这不是一个数字吗?
谢谢。
目前没有回答
相关问题 更多 >
编程相关推荐