Python 3 教程教程
Python3 input() 函数
Python3 input() 函数
Python3 input() 函数
Python3.x 中 input() 函数接受一个标准输入数据,返回为 string 类型。
注意:在 Python3.x 中 raw_input() 和 input() 进行了整合,去除了 raw_input( ),仅保留了input( )函数,其接收任意任性输入,将所有输入默认为字符串处理,并返回字符串类型。
函数语法
input([prompt])
参数说明:
- prompt: 提示信息
实例
input() 需要输入 python 表达式
>>>a = input("input:")
input:123 # 输入整数
>>> type(a)
<class 'str'> # 字符串
>>> a = input("input:")
input:verydoc # 正确,字符串表达式
>>> type(a)
<class 'str'> # 字符串
更多内容
Python2.x input 与 raw_input() 说明
Python2.x 和 Python3.x 中 raw_input( ) 和 input( ) 区别
Python3 input() 函数 |
---|
Python 3 教程
Python的3.0版本,常被称为Python 3000,或简称Py3k。相对于Python的早期版本,这是一个较大的升级。为了不带入过多的累赘,Python 3.0在设计的时候没有考虑向下兼容。