当前位置:网站首页>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 :

边栏推荐
- MIT6.S081-Lab9 FS [2021Fall]
- 怎样写一个增广矩阵到txt文件中
- Kirin Xin'an operating system derivative solution | storage multipath management system, effectively improving the reliability of data transmission
- PKPM 2020 software installation package download and installation tutorial
- OpenGL jobs - shaders
- Latest Android advanced interview questions summary, Android interview questions and answers
- Reinforcement learning - learning notes 9 | multi step TD target
- 三元表达式、各生成式、匿名函数
- Paint basic graphics with custompaint
- Attitude estimation (complementary filtering)
猜你喜欢

大数据开源项目,一站式全自动化全生命周期运维管家ChengYing(承影)走向何方?
![[advanced MySQL] index details (I): index data page structure](/img/e7/fe4591a721a71c3c38d6e4448af6af.png)
[advanced MySQL] index details (I): index data page structure
![[azure microservice service fabric] how to transfer seed nodes in the service fabric cluster](/img/b6/e5d525d9c7c28f6ef04c3f59b40eb3.png)
[azure microservice service fabric] how to transfer seed nodes in the service fabric cluster

Anti climbing killer

Matplotlib drawing interface settings

如何选择合适的自动化测试工具?

Why can't win11 display seconds? How to solve the problem that win11 time does not display seconds?

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

Win11时间怎么显示星期几?Win11怎么显示今天周几?

Implementation method of data platform landing
随机推荐
[interview arrangement] 0211 game engine server
Typescript TS basic knowledge type declaration
Revit secondary development - intercept project error / warning pop-up
建立自己的网站(18)
Paint basic graphics with custompaint
Write in front -- Talking about program development
Tcp/ip protocol stack
OpenGL configure assimp
Cannot find module 'xxx' or its corresponding type declaration
How to realize the movement control of characters in horizontal game
Main functions of OS, Sys and random Standard Libraries
Embedded development: how to choose the right RTOS for the project?
OpenGL homework - Hello, triangle
[开源] .Net ORM 访问 Firebird 数据库
[colmap] sparse reconstruction is converted to mvsnet format input
[advanced MySQL] index details (I): index data page structure
This experimental syntax requires enabling the parser plugin: ‘optionalChaining‘
Application practice | the efficiency of the data warehouse system has been comprehensively improved! Data warehouse construction based on Apache Doris in Tongcheng digital Department
怎样写一个增广矩阵到txt文件中
. Net automapper use