Python 2.7.12 - 同时为True,raw_input,如果为isdigit,则为另一个raw_input挂起

时间:2016-10-08 16:24:10

标签: python python-2.7 while-loop raw-input

以下是我的代码,我想要一个数字来处理,在询问其他选项之前检查它是否为数字,如果是另一个有效数字,则在循环中断。

据我所知,在使用和操作数之前我可以问两个问题。但令人惊讶的是,当我运行时,我的python程序总是挂起(没有响应),使用以下代码。我尝试进行故障排除,并意识到它在if循环中有另一个raw_input,任何人都面临同样的问题?或者有什么我错过了吗?

while True:
    testNo = raw_input("Enter the number you want to test:")
    if testNo.isdigit() == True:
        testOp = raw_input("Choose your option:1 - double, 2 - square, 3 - cube:")
        if testOp > 0 and testOp <= 3:
            break
        else:
            continue
    else:
        continue

0 个答案:

没有答案