【问题标题】:I'm trying to loop a basic userInput script in python我正在尝试在 python 中循环一个基本的 userInput 脚本
【发布时间】:2017-05-30 00:38:27
【问题描述】:

我在中间进行基本的种族选择输入。

userInput = input
print ('I choose a(n)', userInput)
if userInput is ('Human'):
    input ('I like Humans, help that I am one')    
if userInput is ('Orc'):
    print ('Hate orcs, I dont like green :(')
if userInput is ('Android'):
    print ('Robots are cool, so by theory Androids are too')
else:
    print ('Try Again')

但是输出很奇怪...

I choose a(n) <built-in function input>

Try Again

看到脚本的问题了吗?我认为它不会等待输入,因为没有输入,它只是说“再试一次”,但我不完全确定如何解决这个问题。 这可能是一个简单的解决方法,但我真的不知道 :(

【问题讨论】:

    标签: python python-3.x input user-input


    【解决方案1】:

    试试

    userInput = input()
    

    input()是函数调用

    【讨论】:

    • @Samuel Quansah 如果我的回答解决了您的问题,请接受。
    猜你喜欢
    • 2021-10-02
    • 2015-09-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-02-11
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多