当前位置:网站首页>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 :
边栏推荐
- How to close eslint related rules
- Reinforcement learning - learning notes 9 | multi step TD target
- IP网络主动测评系统——X-Vision
- How to turn on win11 game mode? How to turn on game mode in win11
- Revit secondary development - get the project file path
- Antd date component appears in English
- Typeorm automatically generates entity classes
- The whole network "chases" Zhong Xuegao
- Embedded development: how to choose the right RTOS for the project?
- Win11时间怎么显示星期几?Win11怎么显示今天周几?
猜你喜欢
Node:504 error reporting
Index summary (assault version)
Ternary expressions, generative expressions, anonymous functions
新版代挂网站PHP源码+去除授权/支持燃鹅代抽
vite Unrestricted file system access to
客户案例|华律网,通过观测云大幅缩短故障定位时间
The whole network "chases" Zhong Xuegao
强化学习-学习笔记9 | Multi-Step-TD-Target
How to choose the appropriate automated testing tools?
How to realize the movement control of characters in horizontal game
随机推荐
[开源] .Net ORM 访问 Firebird 数据库
Use partial derivatives to display normals in unity
反爬通杀神器
MIT6.S081-Lab9 FS [2021Fall]
OpenGL job - texture
【Azure微服务 Service Fabric 】因证书过期导致Service Fabric集群挂掉(升级无法完成,节点不可用)
Anti climbing killer
Jerry's test box configuration channel [chapter]
Attitude estimation (complementary filtering)
Revit secondary development - intercept project error / warning pop-up
Vs custom template - take the custom class template as an example
DBSync新增对MongoDB、ES的支持
如何选择合适的自动化测试工具?
Remove the default background color of chrome input input box
MIT6.S081-Lab9 FS [2021Fall]
Get the week start time and week end time of the current date
如何选择合适的自动化测试工具?
Xcode modifies the default background image of launchscreen and still displays the original image
It's worth seeing. Interview sites and interview skills
OpenGL jobs - shaders