当前位置:网站首页>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 :
边栏推荐
- 使用 CustomPaint 绘制基本图形
- 强化学习-学习笔记9 | Multi-Step-TD-Target
- 双塔模型的最强出装,谷歌又开始玩起“老古董”了?
- OpenGL configure assimp
- Jerry's configuration of TWS cross pairing [article]
- Get the week start time and week end time of the current date
- PDF文档签名指南
- Embedded development: how to choose the right RTOS for the project?
- Record a garbled code during servlet learning
- 【Azure微服务 Service Fabric 】因证书过期导致Service Fabric集群挂掉(升级无法完成,节点不可用)
猜你喜欢
Preparing for the interview and sharing experience
648. Word replacement
Tcp/ip protocol stack
Latest Android advanced interview questions summary, Android interview questions and answers
Use blocconsumer to build responsive components and monitor status at the same time
How does win11 time display the day of the week? How does win11 display the day of the week today?
Jerry's test box configuration channel [chapter]
Dayu200 experience officer MPPT photovoltaic power generation project dayu200, hi3861, Huawei cloud iotda
How to make agile digital transformation strategy for manufacturing enterprises
Display optimization when the resolution of easycvr configuration center video recording plan page is adjusted
随机推荐
How does win11 time display the day of the week? How does win11 display the day of the week today?
Get the exact offset of the element
强化学习-学习笔记9 | Multi-Step-TD-Target
Why can't win11 display seconds? How to solve the problem that win11 time does not display seconds?
Revit secondary development - intercept project error / warning pop-up
IP网络主动测评系统——X-Vision
Which futures company is the safest to open a futures account?
How to write an augmented matrix into TXT file
使用 BlocConsumer 同时构建响应式组件和监听状态
Ternary expressions, generative expressions, anonymous functions
【Azure微服务 Service Fabric 】如何转移Service Fabric集群中的种子节点(Seed Node)
【Azure微服务 Service Fabric 】因证书过期导致Service Fabric集群挂掉(升级无法完成,节点不可用)
operator
How to turn on win11 game mode? How to turn on game mode in win11
建立自己的网站(18)
Win11如何解禁键盘?Win11解禁键盘的方法
应用实践 | 数仓体系效率全面提升!同程数科基于 Apache Doris 的数据仓库建设
npm uninstall和rm直接删除的区别
Jerry's configuration of TWS cross pairing [article]
Anti climbing killer