当前位置:网站首页>How to judge whether the input content is "number"
How to judge whether the input content is "number"
2022-07-07 22:26:00 【Happy learning Python】
When you want users to enter a number , Will use input function , however input The function does not restrict what the user enters , Users can also enter string or other format content .
Run the following code :

When the user enters the correct number , Output is as follows :

When user input error , Output is as follows

If you want users to input numbers as required, you need to judge the user's input content and then output .
Because the string content cannot be converted to floating point (float), You can convert user input to floating point (float) As the result of the True still False To judge .
Run the following code

If the input is not a number , Output is as follows :

边栏推荐
- 【Azure微服务 Service Fabric 】如何转移Service Fabric集群中的种子节点(Seed Node)
- Tcp/ip protocol stack
- Px4 autonomous flight
- Anti climbing killer
- Tsconfig of typescript TS basics JSON configuration options
- Node:504 error reporting
- SAR影像质量评估
- Oracle advanced (VI) Oracle expdp/impdp details
- Song list 11111
- 强化学习-学习笔记9 | Multi-Step-TD-Target
猜你喜欢

It's worth seeing. Interview sites and interview skills

The whole network "chases" Zhong Xuegao

Dayu200 experience officer MPPT photovoltaic power generation project dayu200, hi3861, Huawei cloud iotda

operator

Paint basic graphics with custompaint

The latest Android interview collection, Android video extraction audio

IP网络主动测评系统——X-Vision
![Jerry's initiation of ear pairing, reconnection, and opening of discoverable and connectable cyclic functions [chapter]](/img/14/1c8a70102c106f4631853ed73c4d82.png)
Jerry's initiation of ear pairing, reconnection, and opening of discoverable and connectable cyclic functions [chapter]

强化学习-学习笔记9 | Multi-Step-TD-Target

null == undefined
随机推荐
How does win11 time display the day of the week? How does win11 display the day of the week today?
PKPM 2020软件安装包下载及安装教程
Relationship between URL and URI
Remove the default background color of chrome input input box
23. Merge K ascending linked lists -c language
Preparing for the interview and sharing experience
反爬通杀神器
【colmap】稀疏重建转为MVSNet格式输入
Vs custom template - take the custom class template as an example
[advanced MySQL] index details (I): index data page structure
VTOL in Px4_ att_ Control source code analysis [supplement]
强化学习-学习笔记9 | Multi-Step-TD-Target
【Azure微服务 Service Fabric 】在SF节点中开启Performance Monitor及设置抓取进程的方式
海外代理推荐
TCP/IP 协议栈
DBSync新增对MongoDB、ES的支持
变量与常量
Two kinds of updates lost and Solutions
Aspose. Word operation word document (II)
Pdf document signature Guide