TypeError:输入最多需要1个参数,是否有4个?pythonx和o';s游戏
所以我正在做这个X和O的游戏,在测试的时候我发现了这个错误,我不知道为什么或者如何修复它。它发生在我触发intro函数时,用户必须选择there模式TypeError:输入最多需要1个参数,是否有4个?pythonx和o';s游戏,python,python-3.x,atom-editor,Python,Python 3.x,Atom Editor,所以我正在做这个X和O的游戏,在测试的时候我发现了这个错误,我不知道为什么或者如何修复它。它发生在我触发intro函数时,用户必须选择there模式 ####PROGRAM IMPORTS BELOW#### import time import random ####PROGRAM CLASSES#### ####PROGRAM FUNCTIONS BELOW#### def choosemode(): desiredmode = int(input("PLEASE ENTER
####PROGRAM IMPORTS BELOW####
import time
import random
####PROGRAM CLASSES####
####PROGRAM FUNCTIONS BELOW####
def choosemode():
desiredmode = int(input("PLEASE ENTER 1 OR 2 TO PLAY" , '\n' , "OR 3 FOR HTP" , '\n' ))
if desiredmode == 1 :
onep()
elif desiredmode == 2 :
twop()
elif desiredmode == 3 :
HTP()
else :
choosemode()
def gamemodes():
gm1 , gm2 , gm3 = (" 1 PLAYER" , " 2 PLAYER" , " HOW TO PLAY")
print ( '\n' , gm1 , '\n' , gm2 , '\n' , gm3 , '\n' )
return
def boardformat():
print (" 0 | 1 | 2 ")
print ("-----------")
print (" 3 | 4 | 5 ")
print ("-----------")
print (" 6 | 7 | 8 ")
def boardatplay():
print ( b0, "|" ,b1, "|" ,b2 )
print ("--------------------")
print ( b3, "|" ,b4, "|" ,b5 )
print ("--------------------")
print ( b6, "|" ,b7, "|" ,b8 )
def restartboard():
b0 = b1 = b2 = b3 = b4 = b5 = b6 = b7 = b8 = (" ")
def checkforwinx():
if b0 & b1 & b2 == "X" or b3 & b4 & b5 == "X" or b6 & b7 & b8 == "X" or b0 & b3 & b6 == "X" or b1 & b4 & b7 == "X" or b2 & b5 & b8 == "X" or b0 & b4 & b8 == "X" or b2 & b4 & b6 == "X" :
print ("X WINS!")
def checkforwino():
if b0 & b1 & b2 == "O" or b3 & b4 & b5 == "O" or b6 & b7 & b8 == "O" or b0 & b3 & b6 == "O" or b1 & b4 & b7 == "O" or b2 & b5 & b8 == "O" or b0 & b4 & b8 == "O" or b2 & b4 & b6 == "O" :
print ("O WINS!")
def intro():
print ("WELCOME TO X and O's PYTHON EDITION!", '\n' ,"WHAT WOULD YOU LIKE TO PLAY?")
gamemodes()
choosemode()
def onep():
print ( "ONE PLAYER SELECTED!" )
print ( "PLEASE ENTER YOUR NAME" )
name1 = input()
print ( name1 , "VS COMPUTER" )
print ( "PRESS ENTER WHEN READY!")
input()
def twop():
print ( "TWO PLAYER SELECTED!" )
def HTP():
print( "1) To plot a point type the number of the area you want plot in" )
boardformat()
print( "2) " )
####PROGRAM BEGINS BELOW####
restartboard()
print ( "LOADING..." )
time.sleep(4)
print ( "READY!" )
time.sleep(2)
print ( "A EUAN DEAS PRODUCTION" + '\n' )
time.sleep(2)
intro()
我得到一个错误:
Traceback (most recent call last):
File "C:\Users\Euan\Desktop\Programming stuff\Python\X and O's.py", line 81, in <module>
intro()
File "C:\Users\Euan\Desktop\Programming stuff\Python\X and O's.py", line 54, in intro
choosemode()
File "C:\Users\Euan\Desktop\Programming stuff\Python\X and O's.py", line 11, in choosemode
desiredmode = int(input("PLEASE ENTER 1 OR 2 TO PLAY" , '\n' , "OR 3 FOR HTP" , '\n' ))
TypeError: input expected at most 1 arguments, got 4
回溯(最近一次呼叫最后一次):
文件“C:\Users\Euan\Desktop\Programming stuff\Python\X和O's.py”,第81行,在
简介()
文件“C:\Users\Euan\Desktop\Programming stuff\Python\X和O's.py”,第54行,在简介中
choosemode()
文件“C:\Users\Euan\Desktop\Programming stuff\Python\X和O's.py”,第11行,在choosemode中
desiredmode=int(输入(“请输入1或2以播放”、“\n”、”或3以播放HTP”、“\n”))
TypeError:输入最多需要1个参数,得到4个
您将四个字符串作为参数输入。只要把他们连在一起
"PLEASE ENTER 1 OR 2 TO PLAY\nOR 3 FOR HTP\n"
使用“+”或字符串格式,或者只在一个字符串中键入它们。很明显,您正在将4个字符串放入
输入
,正如错误所示…