前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Python基础 input()的使用

Python基础 input()的使用

作者头像
py3study
发布2020-01-17 11:25:12
3910
发布2020-01-17 11:25:12
举报
文章被收录于专栏:python3python3

input()函数用于读取标准输入 注意:input函数的返回值类型为字符串

代码语言:javascript
复制
        >>> num=input("Please input a number:")
        Please input a number:32
        >>> type(num)
        <class 'str'>

        >>> num1=input("Please input the number1:")
        Please input the number1:5
        >>> num2=input("Please input the number2:")
        >>> print("number1 + number2 =",(num1+num2))
        number1 + number2 = 53
        >>> print("number1 + number2 =",(int(num1)+int(num2)))
        number1 + number2 = 8
代码语言:javascript
复制
        >>> cus=input("Please input the custom name:")
        Please input the custom name:Tom
        >>> cid=input("Please input the custom ID:")
        Please input the custom ID:001
        >>> cus_info='''
                        custom_name:{0}
                        custom_id:{1}
                        '''.format(cus,cid)
        >>> print(cus_info)
        custom_name:Tom
        custom_id:001
本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2019-06-24 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档