Python - User input data type

前端 未结 3 944
我在风中等你
我在风中等你 2021-01-24 13:05

I\'ve written the following code in Python 3.x to validate the user\'s input:

while True:
    try:
        answer = int(input(\"Enter an integer: \"))
    except         


        
3条回答
  •  一整个雨季
    2021-01-24 13:14

    String, everything that you input() will be a string. And all of them will raise value error except for C-c if int() raises it.

提交回复
热议问题