python输入浮点数_Python3基础 input 输入浮点数,整数,字符串

本文介绍了如何在Python3中使用`input()`函数获取浮点数、整数和字符串输入。通过示例代码展示了输入处理过程,并提到了Python的特性和设计哲学,强调了遵循编码规范的重要性。
摘要由CSDN通过智能技术生成

Python : 3.7.0

OS : Ubuntu 18.04.1 LTS

IDE : PyCharm 2018.2.4

Conda : 4.5.11

typesetting : Markdown

code

"""

@Author : 行初心

@Date : 18-9-24

@Blog : www.cnblogs.com/xingchuxin

@Gitee : gitee.com/zhichengjiu

"""

def main():

my_float = float(input('请输入一个浮点数:'))

my_int = int(input('请输入一个整数:'))

my_str = input('请输入一个字符串:')

if __name__ == '__main__':

main()

result

/home/coder/anaconda3/envs/py37/bin/python /home/coder/PycharmProjects/basic/demo.py

请输入一个浮点数:1.2

请输入一个整数:25

请输入一个字符串:hello

Process finished with exit code 0

more knowledge

Help on built-in function input in module builtins:

input(prompt=None, /)

Read a string from standard input. The trailing newline is stripp

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值