Python基础input()的使用

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

网站建设哪家好,找创新互联公司!专注于网页设计、网站建设、微信开发、成都小程序开发、集团企业网站建设等服务项目。为回馈新老客户创新互联还提供了临城免费建站欢迎大家使用!

        >>> num=input("Please input a number:")
        Please input a number:32
        >>> type(num)
        

        >>> 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

文章名称:Python基础input()的使用
网页链接:http://hxwzsj.com/article/jdpcei.html

其他资讯

Copyright © 2025 青羊区翔捷宏鑫字牌设计制作工作室(个体工商户) All Rights Reserved 蜀ICP备2025123194号-14
友情链接: 成都网站建设公司 成都网站设计 重庆手机网站建设 成都网站制作 成都网站设计公司 成都网站设计 成都网站建设 重庆网站建设 高端网站设计推广 成都模版网站建设 成都商城网站制作 定制级高端网站建设 营销型网站建设 专业网站设计 成都网站制作 重庆电商网站建设 成都网站建设推广 公司网站建设 高端品牌网站建设 成都网站设计 企业网站设计 成都网站建设