Python:TypeError:输入最多需要1个参数,得到3

时间:2016-10-18 19:14:14

标签: python variables

这是我的代码:

print("Hello, what's your name?")
myName = sys.stdin.readline()
Join = input("Would you like to play a game, yes or no?").lower()
if Join.startswith('y'):
    print("Fine, you can play.")
else:
    print("Ok, goodbye.")
    sys.exit()
Color = input("So, first question. What's your favorite colour,
or do you have none?").lower()
if Color.startswith("n"):
    Thanks = input("Didn't expect much from you, good job", myName, 
" Say thanks, I complimented you!").lower()
else:
    print("Having a favorite colour is the wrong answer, try again.")
    sys.exit()
if Thanks.lower() == 'thanks':
    print("NEVER SAY THANKS!")
    sys.exit()
else:
    Continue = input("Well done, you didn't say THANKS. 
    Do you wish to  continue, yes or no?").lower()
if Continue.startswith('y'):
    print("Sure let's continue then.")
else:
    print("Too bad, you HAVE to continue!")
    sys.exit()

我是编程新手,而我只是制作了一个笑话"代码练习。但是我一直在这条线上出错:

Thanks = input("Didn't expect much from you, good job", myName, " Say thanks, I complimented you!").lower()

错误是:

  

TypeError:输入最多需要1个参数,得到3

2 个答案:

答案 0 :(得分:1)

输入只有一个参数,你提供3。

要连接字符串,您可以使用+而不是,

Thanks = input("Didn't expect much from you, good job "+ myName + +" Say thanks, I complimented you!").lower()

答案 1 :(得分:1)

请改为:

SELECT CONVERT('Ä Ê Í Õ Ø A B C D E ', 'UTF8', 'US7ASCII') 

由于“,”,它将其作为参数获取并且不会连接字符串