我不明白,我的代码出了什么问题?

时间:2017-09-04 14:32:13

标签: python

我不明白,我的代码出了什么问题?每当我输入heyhisup时,它都不会显示我在代码中写的内容,但会显示其他内容 - 我犯的错误是什么?

这是我的代码:

import os
import random
import time

for i in range(1, 2):

    a = random.choice(("hi, sir", "hey, sir", "hello, sir", "sup, sir", "Joe Reporting, Sir"))
    print(a)
    os.system("say '"+a+"'")


res1 = input()

if res1 is ("hi", "hey", "hello", "sup", "Hey Joe"):
    GE = ("I am Joe, Your New Personal Assintant. Nice to meet you.")
    print(GE)
    os.system("say '"+GE+"'")
else:
    js = random.choice(("okay, what would you like to do", "So, Sir What Would you like to do ", "So Sir, What to do", "k, what are we going to do"))
    print(js)
    os.system("say '"+js+"'")


User_inp = input()
print("Ok, searching")
'''
if inp  "?":
    print("Um...Let me Search")
'''
Next_inp = input()
g = random.choice(("Searching, sir", "I am on it."))
print(g)

1 个答案:

答案 0 :(得分:1)

如评论中所述,您必须像这样修改您的代码。

res1 = input()

if res1 in ("hi", "hey", "hello", "sup", "Hey Joe"):
    GE = ("I am Joe, Your New Personal Assintant. Nice to meet you.")
    print(GE)
    os.system("say '"+GE+"'")

你混淆了inis的影响;因此,在初始代码中使用is更改in可以解决您的问题。