python如何判断输入都是字母


当前第2页 返回上一页

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

str_1 = "123"

str_2 = "Abc"

str_3 = "123Abc"

 

#用isdigit函数判断是否数字

print(str_1.isdigit())

Ture

print(str_2.isdigit())

False

print(str_3.isdigit())

False

 

#用isalpha判断是否字母

print(str_1.isalpha())   

False

print(str_2.isalpha())

Ture   

print(str_3.isalpha())   

False

 

#isalnum判断是否数字和字母的组合

print(str_1.isalnum())   

Ture

print(str_2.isalnum())

Ture

print(str_1.isalnum())   

Ture

注意:如果字符串中含有除了字母或者数字之外的字符,比如空格,也会返回False

以上就是python如何判断输入都是字母的详细内容,更多文章请关注木庄网络博客!!

返回前面的内容

相关阅读 >>

Python matplotlib坐标轴设置的方法

Python matplotlib中文显示参数设置解析_Python

Python对文件操作采用的统一步骤是什么

如何利用Python实现购物程序思路以及实现代码

Python自带numpy吗

Python中降序用哪个单词

Python如何利用lxml对xml进行读写操作教程

Python怎么安装plotly

Python语言是一种什么类型

手把手教你在Python中如何使用while true语句

更多相关阅读请进入《Python》频道 >>




打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...