Python中判断输入数据的类型
2016-10-25 17:21
218 查看
在接收input()输入的数据后,判断接收到的字符串是否为数字
例如:
str = input("please enter something:")
if str.isdigit():为True表示输入的所有字符都是数字,否则,不是全部为数字
str为字符串
str.isalnum() 所有字符都是数字或者字母
str.isalpha() 所有字符都是字母
str.isdigit() 所有字符都是数字
str.islower() 所有字符都是小写
str.isupper() 所有字符都是大写
str.istitle() 所有单词都是首字母大写,像标题
str.isspace() 所有字符都是空白字符、\t、\n、\r
例如:
str = input("please enter something:")
if str.isdigit():为True表示输入的所有字符都是数字,否则,不是全部为数字
str为字符串
str.isalnum() 所有字符都是数字或者字母
str.isalpha() 所有字符都是字母
str.isdigit() 所有字符都是数字
str.islower() 所有字符都是小写
str.isupper() 所有字符都是大写
str.istitle() 所有单词都是首字母大写,像标题
str.isspace() 所有字符都是空白字符、\t、\n、\r
相关文章推荐
- Python动态类型,怎么判断是输入数据的合法性?
- 以写代学:python 数据类型之字符串,判断用户输入的id是否符合要求
- Python 判断变量的数据类型
- 1.20 Java基础总结 输入数据类型判断 Java低耦合原则 for嵌套思路
- Python如何判断<type 'NoneType'>数据类型
- Python入门(输入/输出、数据类型、条件/循环语句)
- python中如何判断变量的数据类型
- python 学习笔记day01-python概述、安装、数据类型、if判断
- 如何判断python的数据类型,用type函数
- Python教程学习简记1--Python数据类型和变量 字符串和编码 list和tuple 条件判断 循环 dict和set
- 在ASP中判断一个TEXT里输入的数据类型
- python中如何判断一个变量的数据类型?(原创)
- python中如何判断一个变量的数据类型
- 判断数据类型 python
- python数据类型判断type与isinstance的区别
- python中如何判断一个变量的数据类型?(原创)
- python 判断数据类型
- Python 判断变量的数据类型
- Python学习--判断变量的数据类型
- Python的数据类型转换、类型判断等