当前位置:网站首页>打卡day05
打卡day05
2022-08-02 05:52:00 【huixiaodezuotian】
"""
Python isdigit() 方法检测字符串是否只由数字组成,只对 0 和 正数有效。
语法:str.isdigit()
参数:无
返回值:如果字符串只包含数字则返回 True 否则返回 False。
"""
str ='123456'
print(str.isdigit())
str = 'Hello,World!'
print(str.isdigit())
str = '-1'
print(str.isdigit())
def is_ip(ip):
num_list = ip.split(".")
for num in num_list:
# igit是数字的意思, isdigit就是判断是否是数字, 0 - 9就是数字
if not num.isdigit() or not 0<= int(num)<=255:
return False
return True
print(is_ip("10.289.122.55"))
打印结果:
True
False
False
False
边栏推荐
猜你喜欢
Nacos安装详细过程
推出 Space On-Premises (本地部署版) Beta 版!
Node installation and configuration (node-v12.20.2-x64 ) and introduction to node version switching
秒杀系统小demo
MySQL经典50道练习题及全网最详细解析
Nacos installation configuration and single-machine deployment tutorial
HCIP 第二天
能与观众实时互动的Claper
MySQL高级SQL语句(二)
Nodejs installation tutorial
随机推荐
[数据集][VOC]眼睛佩戴数据集VOC格式6000张
Node installation and configuration (node-v12.20.2-x64 ) and introduction to node version switching
MySQL - Multi-table query and case detailed explanation
Nodejs installation and global configuration (super detailed)
nacos安装配置和单机部署教程
MySQL classic 50 practice questions and the most detailed analysis of the whole network
[Cartoon] 2021 full score programmer behavior comparison table (latest version)
金蝶国际:半年亏掉去年一年,疯狂烧钱的商业模式如何持续
rhce作业
zabbix email alarm and WeChat alarm
MySQL database video tutorial from beginner to proficient
反向解析dns服务器
love
HCIP 第三天实验
HCIP第十七天
Kingdee International: Lost in half a year and last year, how does the business model of frantically burning money continue
MySQL高级SQL语句
一文搞懂C操作符
npm 和 yarn的区别
Common functions of pytorch