2024-04-26 12:53:41 发布
网友
我有一个表单值:
anytext = request.POST.get("my_text", None) if anytext and anytext.is_string: perform any action if anytext and anytext.is_numeric: perform another action
如何检查数值??在
你可以试试:
if int(re.search(r'\d+', anytext).group())): #perform action
您可以使用isdigit(),假设anytext总是string类型。在
isdigit()
anytext
string
例如:
'Hello World'.isdigit() # returns False '1234243'.isdigit() # returns True
你的代码:
你可以试试:
您可以使用
isdigit()
,假设anytext
总是string
类型。在例如:
你的代码:
^{pr2}$相关问题 更多 >
编程相关推荐