>>type(num) 发布时间:2019-06-24 15:58:21编辑:auto阅读(1734) input()函数用于读取标准输入
上一篇:
python之语句 下一篇:
Python - logging模块 46483 44374 35824 33379 28077 24642 23567 18782 18039 16727 4548° 5104° 4636° 4778° 5439° 4402° 4456° 5002° 4893° 6142° Python基础 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