大家好,我试图在for循环内创建N个对象,但这给了我一个错误TypeError: cannot unpack non-iterable Jugador object
。
你能帮我吗?
我做错了什么?
这是我的代码:
from Jugador import Jugador
class Juego():
tipoJuego = ""
nJugadores = ""
def __init__(self,tipoJuego, nJugadores):
self.tipoJuego = tipoJuego
self.nJugadores = nJugadores
nJugadoresInt = int(nJugadores)
tipoJuegoInt = int(tipoJuego)
if tipoJuegoInt == 1 or tipoJuegoInt == 2 or tipoJuegoInt == 3:
print("Has elegido el tipo de juego ",tipoJuegoInt, ", y van a jugar ", nJugadores, " Personas")
else:
print("Error: Tipo de juego invalido")
exit()
for i in range(1,nJugadoresInt):
print("Jugador",i, "introduzca el nombre de usuario:")
nUsu = input()
print("Introduzca la edad:")
age = input()
print("Introduzca la palabra elegida:")
word = input()
J,i = Jugador(nUsu, age, word)
答案 0 :(得分:0)
如果您打算创建一种分配N个对象以便稍后找到它们的方法,我建议将它们存储在列表names(training) <- make.names(names(training))
n <- neuralnet(price ~ .,
data = training,
hidden = 1,
err.fct = "sse",
linear.output = FALSE)
n$weights
#[[1]]
#[[1]][[1]]
# [,1]
# [1,] -0.62625018
# [2,] 1.39124245
# [3,] -2.59472834
# [4,] 0.27773897
# [5,] 7.15830865
# [6,] -2.93583230
# ...
中:
J
供参考:https://docs.python.org/3.8/tutorial/datastructures.html