Python basic input () use

input () function is used to read standard input
Note: input type of the function return value is a string

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

Guess you like

Origin blog.51cto.com/5279100/2407457
Recommended