首页 > 编程语言 >python5

python5

时间:2022-12-08 18:56:41浏览次数:42  
标签:号码 程序员 mobile idcard print python5 match

一、使用字符串拼接输出一个关于程序员的笑话

programmer_1='程序员甲:搞IT太辛苦了,我想换行……怎么办?'
programmer_2='程序员乙:敲一下回车键'
print(programmer_1+programmer_2)

 

 

 二、截取身份证号码中的出生日期

programer_1='你知道我的生日吗?'
print('程序员甲说:',programer_1)
programer_2='输入你的身份证号码。'
print('程序员乙说:',programer_2)
idcard='123456199006277890'
print('程序员甲说:',idcard)
birthday=idcard[6:10]+'年'+idcard[10:12]+'月'+idcard[12:14]+'日'
print('程序员乙说:','你是'+birthday+'出生的,所以你的生日是'+birthday[5:])

 

 

 三、输出被@的好友名称

str11='@明日科技 @扎克伯格 @俞敏洪'
list1=str.split('')
print('您@的好友有:')
for item in list1:
print(item[1:])

 

 

 

 

 四、通过好友列表生成全部被@的好友

list_friend=['明日科技','扎克伯格','俞敏洪','马云','马化腾']
str_friend='@'.join(list_friend)
at='@'+str_friend
print('您要@的好友:',at)

 

 

 五、验证输入的手机号码是否为中国移动的号码

import re
pattern=r'(13[4-9]\d{8})$|(15[0129]\d{8})$'
mobile='13634222222'
match=re.match(pattern,mobile)
if match==None:
print(mobile,'不是有效的中国移动号码。')
else:
print(mobile,'是有效的中国移动号码。')
mobile='13144222221'
match=re.match(pattern,mobile)
if match==None:
print(mobile,'不是有效的中国移动号码。')
else:
print(mobile,'是有效的中国移动号码。')

 

 

标签:号码,程序员,mobile,idcard,print,python5,match
From: https://www.cnblogs.com/666k/p/16966976.html

相关文章

  • 新的学习历程-python5 输入输出基础
    1uname=input("pleaseinputusername:")2print("welcome",uname)#print各项间默认以空格作为分隔符3print("welcome"+uname)#注意引号内最后的空格学习资源来......
  • Python5-
    实战01(打印象棋口诀)1str1='马走日'2str2=','3str3='象走田'4str4=','5str5='车走直线炮翻山'6str6=','7str7='士走斜线护将边'8st......
  • python5-eg
    1实例012programmer_1='程序员甲:搞IT太辛苦了,我想换行......怎么办?'3programmer_2='程序员乙:敲一下回车键'4print(programmer_1+'\n'+programmer_2)实......
  • python5种线程锁
    # 线程安全线程安全是多线程或多进程编程中的一个概念,在拥有共享数据的多条线程并行执行的程序中,线程安全的代码会通过同步机制保证各个线程都可以正常且正确的执行,不会......
  • python5
    python数据类型数据类型-布尔值(bool)1.判断失误的对错是否可行只用于流程控制中2.只有两种状态:True对的False错的3.python中所有数值自带布尔值......