-3

I'm doing a RogueLike game with Python and I use a DungeonGenerator.py. In my game I read the dungeons from a .txt file.

The problem is I can't write the dungeon I make with the DungeonGenerator.py on a .txt file because is a matrix of strings.

This is an example of the result of DungeonGenerator.py:

Dungeon example

I try with:

return tiles
file = open ("Dungeon.txt", "w")
file.write(tiles)
file.close()

Obiously tiles isn't a string.

Thanks in advice!

1 Answers1

0

What you want to do is called object serialization.

The pickle module should work just fine for you.

Ellis Michael
  • 962
  • 1
  • 8
  • 14
  • Thanks for the answer..but it doesn't work to me because the data in the .txt is not like I need to read late with my main program. – SinnerKeey Jun 14 '16 at 10:01