0
点赞
收藏
分享

微信扫一扫

Python判断字符串是否以字母开头

一叶轻舟okok 2022-02-17 阅读 104


直接上代码吧

import re
rule = re.compile('^[a-zA-z]{1}.*$')
str='123'
if rule.match(str) is None:
print(str+'不以字母开头')
else:
print(str+'以字母开头')

str2='a12'
if rule.match(str2) is None:
print(str2+'不以字母开头')
else:
print(str2+'以字母开头')



举报

相关推荐

0 条评论