Cannot execute python game
up vote
0
down vote
favorite
i have a game wich was programmed on python 2 apparently, and i need to change it to python 3 code style, im a begginer on this so there's a lot i don't know, so far the only thing i could change was the prints wich only needed parenthesis. My current problem is the following:
File "A:DescargasGalacticWarsGalacticWarsgalacticWars.py", line 984, in <module>
main()
File "A:DescargasGalacticWarsGalacticWarsgalacticWars.py", line 979, in main
escena.update()
File "A:DescargasGalacticWarsGalacticWarsgalacticWars.py", line 102, in update
funcion()
File "A:DescargasGalacticWarsGalacticWarsgalacticWars.py", line 150, in nuevo_juego
escena = Game()
File "A:DescargasGalacticWarsGalacticWarsgalacticWars.py", line 554, in __init__
self.record = pickle.load(self.records)
TypeError: a bytes-like object is required, not 'str'
The lines have this:
984 and 985
if __name__ == "__main__":
main()
976 to 981
# Bucle principal.
while True:
# Actualizamos la escena.
escena.update()
escena.imprimir(screen)
clock.tick(60)
89 to 102:
def update(self):
# Altera la opción seleccionada con las teclas cursor.
key = pygame.key.get_pressed()
if not self.mantiene_pulsado:
if key[K_UP]:
self.seleccionado -= 1
elif key[K_DOWN]:
self.seleccionado += 1
elif key[K_RETURN]:
# Invoca a la función asociada a la opción-
titulo, funcion = self.opciones[self.seleccionado]
print 'Selecionando función:', repr(titulo)
funcion()
146 to 150:
# Función para comenzar el nuevo juego.
def nuevo_juego():
# Pasamos la variable global escena.
global escena
escena = Game()
552 to 556:
# Vamos a otener el Hi-score.
self.records = open('records', 'r')
self.record = pickle.load(self.records)
self.records.close()
print 'Cargando Record:', self.record
python pygame
add a comment |
up vote
0
down vote
favorite
i have a game wich was programmed on python 2 apparently, and i need to change it to python 3 code style, im a begginer on this so there's a lot i don't know, so far the only thing i could change was the prints wich only needed parenthesis. My current problem is the following:
File "A:DescargasGalacticWarsGalacticWarsgalacticWars.py", line 984, in <module>
main()
File "A:DescargasGalacticWarsGalacticWarsgalacticWars.py", line 979, in main
escena.update()
File "A:DescargasGalacticWarsGalacticWarsgalacticWars.py", line 102, in update
funcion()
File "A:DescargasGalacticWarsGalacticWarsgalacticWars.py", line 150, in nuevo_juego
escena = Game()
File "A:DescargasGalacticWarsGalacticWarsgalacticWars.py", line 554, in __init__
self.record = pickle.load(self.records)
TypeError: a bytes-like object is required, not 'str'
The lines have this:
984 and 985
if __name__ == "__main__":
main()
976 to 981
# Bucle principal.
while True:
# Actualizamos la escena.
escena.update()
escena.imprimir(screen)
clock.tick(60)
89 to 102:
def update(self):
# Altera la opción seleccionada con las teclas cursor.
key = pygame.key.get_pressed()
if not self.mantiene_pulsado:
if key[K_UP]:
self.seleccionado -= 1
elif key[K_DOWN]:
self.seleccionado += 1
elif key[K_RETURN]:
# Invoca a la función asociada a la opción-
titulo, funcion = self.opciones[self.seleccionado]
print 'Selecionando función:', repr(titulo)
funcion()
146 to 150:
# Función para comenzar el nuevo juego.
def nuevo_juego():
# Pasamos la variable global escena.
global escena
escena = Game()
552 to 556:
# Vamos a otener el Hi-score.
self.records = open('records', 'r')
self.record = pickle.load(self.records)
self.records.close()
print 'Cargando Record:', self.record
python pygame
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
i have a game wich was programmed on python 2 apparently, and i need to change it to python 3 code style, im a begginer on this so there's a lot i don't know, so far the only thing i could change was the prints wich only needed parenthesis. My current problem is the following:
File "A:DescargasGalacticWarsGalacticWarsgalacticWars.py", line 984, in <module>
main()
File "A:DescargasGalacticWarsGalacticWarsgalacticWars.py", line 979, in main
escena.update()
File "A:DescargasGalacticWarsGalacticWarsgalacticWars.py", line 102, in update
funcion()
File "A:DescargasGalacticWarsGalacticWarsgalacticWars.py", line 150, in nuevo_juego
escena = Game()
File "A:DescargasGalacticWarsGalacticWarsgalacticWars.py", line 554, in __init__
self.record = pickle.load(self.records)
TypeError: a bytes-like object is required, not 'str'
The lines have this:
984 and 985
if __name__ == "__main__":
main()
976 to 981
# Bucle principal.
while True:
# Actualizamos la escena.
escena.update()
escena.imprimir(screen)
clock.tick(60)
89 to 102:
def update(self):
# Altera la opción seleccionada con las teclas cursor.
key = pygame.key.get_pressed()
if not self.mantiene_pulsado:
if key[K_UP]:
self.seleccionado -= 1
elif key[K_DOWN]:
self.seleccionado += 1
elif key[K_RETURN]:
# Invoca a la función asociada a la opción-
titulo, funcion = self.opciones[self.seleccionado]
print 'Selecionando función:', repr(titulo)
funcion()
146 to 150:
# Función para comenzar el nuevo juego.
def nuevo_juego():
# Pasamos la variable global escena.
global escena
escena = Game()
552 to 556:
# Vamos a otener el Hi-score.
self.records = open('records', 'r')
self.record = pickle.load(self.records)
self.records.close()
print 'Cargando Record:', self.record
python pygame
i have a game wich was programmed on python 2 apparently, and i need to change it to python 3 code style, im a begginer on this so there's a lot i don't know, so far the only thing i could change was the prints wich only needed parenthesis. My current problem is the following:
File "A:DescargasGalacticWarsGalacticWarsgalacticWars.py", line 984, in <module>
main()
File "A:DescargasGalacticWarsGalacticWarsgalacticWars.py", line 979, in main
escena.update()
File "A:DescargasGalacticWarsGalacticWarsgalacticWars.py", line 102, in update
funcion()
File "A:DescargasGalacticWarsGalacticWarsgalacticWars.py", line 150, in nuevo_juego
escena = Game()
File "A:DescargasGalacticWarsGalacticWarsgalacticWars.py", line 554, in __init__
self.record = pickle.load(self.records)
TypeError: a bytes-like object is required, not 'str'
The lines have this:
984 and 985
if __name__ == "__main__":
main()
976 to 981
# Bucle principal.
while True:
# Actualizamos la escena.
escena.update()
escena.imprimir(screen)
clock.tick(60)
89 to 102:
def update(self):
# Altera la opción seleccionada con las teclas cursor.
key = pygame.key.get_pressed()
if not self.mantiene_pulsado:
if key[K_UP]:
self.seleccionado -= 1
elif key[K_DOWN]:
self.seleccionado += 1
elif key[K_RETURN]:
# Invoca a la función asociada a la opción-
titulo, funcion = self.opciones[self.seleccionado]
print 'Selecionando función:', repr(titulo)
funcion()
146 to 150:
# Función para comenzar el nuevo juego.
def nuevo_juego():
# Pasamos la variable global escena.
global escena
escena = Game()
552 to 556:
# Vamos a otener el Hi-score.
self.records = open('records', 'r')
self.record = pickle.load(self.records)
self.records.close()
print 'Cargando Record:', self.record
python pygame
python pygame
asked Nov 22 at 13:59
MrBean
31
31
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
accepted
python 2's str is of type "bytes".
python 3's str is of type "unicode".
the short, irresponsible answer would be:
change self.records = open('records', 'r')
to self.records = open('records', 'rb')
the long, responsible answer would be:
read about the topic and handle it in a way which would be proper for ALL your code
Thank you very much, that worked, still got a whole lot bunch of other problems but i managed to solve them so far.
– MrBean
Nov 23 at 3:33
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
accepted
python 2's str is of type "bytes".
python 3's str is of type "unicode".
the short, irresponsible answer would be:
change self.records = open('records', 'r')
to self.records = open('records', 'rb')
the long, responsible answer would be:
read about the topic and handle it in a way which would be proper for ALL your code
Thank you very much, that worked, still got a whole lot bunch of other problems but i managed to solve them so far.
– MrBean
Nov 23 at 3:33
add a comment |
up vote
0
down vote
accepted
python 2's str is of type "bytes".
python 3's str is of type "unicode".
the short, irresponsible answer would be:
change self.records = open('records', 'r')
to self.records = open('records', 'rb')
the long, responsible answer would be:
read about the topic and handle it in a way which would be proper for ALL your code
Thank you very much, that worked, still got a whole lot bunch of other problems but i managed to solve them so far.
– MrBean
Nov 23 at 3:33
add a comment |
up vote
0
down vote
accepted
up vote
0
down vote
accepted
python 2's str is of type "bytes".
python 3's str is of type "unicode".
the short, irresponsible answer would be:
change self.records = open('records', 'r')
to self.records = open('records', 'rb')
the long, responsible answer would be:
read about the topic and handle it in a way which would be proper for ALL your code
python 2's str is of type "bytes".
python 3's str is of type "unicode".
the short, irresponsible answer would be:
change self.records = open('records', 'r')
to self.records = open('records', 'rb')
the long, responsible answer would be:
read about the topic and handle it in a way which would be proper for ALL your code
answered Nov 22 at 14:21
motyzk
844
844
Thank you very much, that worked, still got a whole lot bunch of other problems but i managed to solve them so far.
– MrBean
Nov 23 at 3:33
add a comment |
Thank you very much, that worked, still got a whole lot bunch of other problems but i managed to solve them so far.
– MrBean
Nov 23 at 3:33
Thank you very much, that worked, still got a whole lot bunch of other problems but i managed to solve them so far.
– MrBean
Nov 23 at 3:33
Thank you very much, that worked, still got a whole lot bunch of other problems but i managed to solve them so far.
– MrBean
Nov 23 at 3:33
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53432615%2fcannot-execute-python-game%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown