Python3 input() 函数

Python3 内置函数 Python3 内置函数

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:icodebang # 正确,字符串表达式
>>> type(a)
<class 'str'> # 字符串

更多内容

Python2.x input 与 raw_input() 说明

Python2.x 和 Python3.x 中 raw_input( ) 和 input( ) 区别

Python3 内置函数 Python3 内置函数

0 个评论

要回复文章请先登录注册