PDA

View Full Version : python export/import file



werecatomega
June 7th, 2010, 03:06 AM
Hey guys,
lets say i wanted to make a game that uses a save file (i.e. exports save to "save.txt" and imports it again). How would i do that?

Axos
June 7th, 2010, 07:00 AM
The most basic way to read and write files is introduced in the tutorial. Click the link corresponding to the version of Python you are using.

2.x: http://docs.python.org/tutorial/inputoutput.html
3.x: http://docs.python.org/py3k/tutorial/inputoutput.html

Tony Flury
June 7th, 2010, 09:41 AM
Since the data is unlikely to be just strings, and to save yourself the trouble of having to parse the data etc, look at using pickle.

DanielWaterworth
June 7th, 2010, 05:36 PM
Well, there are a number of things to think about; foremost, what do you want to save? Is it acceptable to be saved in plain-text? Lastly, what format will you use, will you use a standard library like Pickle or json, or will you design your own?

Honestly though, seeing as your asking this question, it's likely that the project that your dreaming of is too difficult for you at this moment in time. Think simpler, make pong and have fun [=