为什么我的 int() 函数不起作用 python 2.7

Why is my int() function not working python 2.7

def game():    

modex = False
while modex == False:
    mode = raw_input("please select a mode: ")
    try:
    ## THE PROBLEM IS HERE!
        int(mode)
        if mode == 1:
            modex = True
            break
        elif mode == 2:
            modex = True
            break
        elif mode == 3:
            modex = True
            break
        else:
            print "invalid #. try again"
            modex == False
            continue

    except:
        print "invalid # try again"
        continue
game()

我好像不能把众数变成整数,例如:

输入:1 输出:无效 # 再试一次

对于我正在制作的游戏,我有 3 种模式,因此 try-except 语句中的 if 语句有 3 种模式

你能帮帮我吗?我正在使用 python 2.7

int(mode) 值赋给某物。最佳方法:mode = int(mode)

您也可以试试:mode = int(raw_input:('please select a mode:'))