Python基础 input()的使用

发布时间:2020-07-05 22:30:38 作者:圣婴大王
来源:网络 阅读:342

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

        >>> 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
        >>> 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
推荐阅读:
  1. python里fd是什么
  2. python使用类是什么时候

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

python input() npu

上一篇:搭建mysql数据库

下一篇:MySQL 创建数据表的命令行

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》