嗨,我对编码还比较陌生,我不知道为什么这段代码不起作用

gender = input("What is your gender(m/f)?")
if gender.upper() == M:
    throw = paper
elif gender.upper() == F:
    throw = rock
else:
    print("issue")
print throw

最佳答案

您正在使用哪个编辑器/运行时?您应该能够配置为在程序退出时使控制台保持打开状态,以便可以看到任何错误。

在您的特定情况下,看起来您正在使用Python 3,并且您还需要在print参数中加上括号:

print(throw)


以及在"M""F"周围使用引号表示它们是字符串。

关于python - 控制台打开,然后立即关闭,但是代码 checkout (Python,Sublime),我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/45779942/

10-12 21:52
查看更多