小白教程
所有教程
关于
Search
172.70.131.101
172.70.131.101
参数设置
贡献
退出
操作
编辑
移动
保护
信息
历史
删除
查看“Python3 func input”的源代码
本页内容
上一节:
Python3_func_enumerate
下一节:
Python3_func_oct
因为以下原因,您没有权限编辑本页:
您请求的操作仅限属于该用户组的用户执行:
用户
您可以查看和复制此页面的源代码。
{{DISPLAYTITLE:input()}}[[Category:python3 built in functions|17]] = Python3 input() 函数 = [[python3 built in functions|Python3 内置函数]] Python3.x 中 input() 函数接受一个标准输入数据,返回为 string 类型。 <blockquote>'''注意:'''在 Python3.x 中 raw_input() 和 input() 进行了整合,去除了 raw_input( ),仅保留了input( )函数,其接收任意任性输入,将所有输入默认为字符串处理,并返回字符串类型。 </blockquote> === 函数语法 === <sample title="" desc="" lang="python" hererun="1"> input([prompt]) </sample> 参数说明: * prompt: 提示信息 == == input() 需要输入 python 表达式 == <sample title="" desc="" lang="python" hererun="1"> >>>a = input("input:") input:123 # 输入整数 >>> type(a) <class 'str'> # 字符串 >>> a = input("input:") input:xiaobai # 正确,字符串表达式 >>> type(a) <class 'str'> # 字符串 </sample> === input() 接收多个值 === <sample title="" desc="" lang="python" hererun="1"> #!/usr/bin/python #输入三角形的三边长 a,b,c = (input("请输入三角形三边的长:").split()) a= int(a) b= int(b) c= int(c) #计算三角形的半周长p p=(a+b+c)/2 #计算三角形的面积s s=(p*(p-a)*(p-b)*(p-c))**0.5 #输出三角形的面积 print("三角形面积为:",format(s,'.2f')) </sample> 以上实例执行输出结果为: <sample title="" desc="" lang="python" hererun="1"> 请输入三角形三边的长:3 4 5 三角形面积为: 6.00 </sample> === 更多内容 === [https://www.xiaobai.wang/python/python-func-input.html Python2.x input 与 raw_input() 说明] [[python2 python3 raw_input and input|Python2.x 和 Python3.x 中 raw_input( ) 和 input( ) 区别]] [[python3 built in functions|Python3 内置函数]]
返回至“
Python3 func input
”。
上一节:
Python3_func_enumerate
下一节:
Python3_func_oct