### python中如何判断输入的值是否是数字

python中如何判断输入的值是否是数字

例如:

str = raw_input(“please input the number:”)

if str.isdigit():

​ print('yes')

为True表示输入的所有字符都是数字,否则,不是全部为数字

str为字符串

str.isalnum() 所有字符都是数字或者字母

str.isalpha() 所有字符都是字母

str.isdigit() 所有字符都是数字

str.islower() 所有字符都是小写

str.isupper() 所有字符都是大写

str.istitle() 所有单词都是首字母大写,像标题

str.isspace() 所有字符都是空白字符、\t、\n、\r

posted @ 2022-07-15 15:34  太白之魔童降世  阅读(559)  评论(0编辑  收藏  举报