详解Python3中的 input() 函数
2020-03-19 12:06
330 查看
一、知识介绍:
1、input() 函数,接收任意输入,将所有输入默认为字符串处理,并返回字符串类型;
2、可以用作文本输入,如用户名,密码框的值输入;
3、语法:input("提示信息:") 。
二、运用演示:
1、接收任意输入,并返回字符串类型;
>>>height = input("输入身高:") #运行
输入身高: 170 #输入整数170
>>> type(a) #type( )检查输出的数据类型
<class 'str'> #字符串
2、想得到一个整数,只需数据类型转换就可以了:
>>> a = int(input("身高:")) #int( ) 转换为整数
身高: 180
>>> type(a)
<class 'int'>
三、案例分析:
总结
到此这篇关于详解Python3中的 input() 函数的文章就介绍到这了,更多相关Python3 input() 函数 内容请搜索脚本之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持脚本之家!
您可能感兴趣的文章:
相关文章推荐
- 对Python3中的input函数详解
- python输入函数input
- python reduce 函数使用详解
- 详解Python中函数参数
- 对python数据清洗容易遇到的函数-re.sub bytes string详解
- Python函数参数详解
- PYTHON学习0043:函数---time模块详解--2019-8-10
- Python中getattr函数和hasattr函数作用详解
- python函数的万能参数传参详解
- Python的hasattr() getattr() setattr() 函数使用方法详解
- Python变量、数据类型、数据类型转换相关函数用法实例详解
- Python sorted函数详解(高级篇)
- python super()函数详解
- Python的hasattr() getattr() setattr()函数使用方法详解
- Python自定义函数的创建、调用和函数的参数详解 .argmax
- 基于Python中求和函数sum的用法详解
- Python help()函数用法详解
- python BIF函数详解
- Python help()函数用法详解
- Python中的getattr()函数详解