Oct-03-2017, 06:59 PM
(Oct-03-2017, 06:53 PM)ichabod801 Wrote: A simple way to do it is just write it tab separated:
with open('character.txt', 'w') as character_file: character_file.write('str\t{}\n'.format(str)) character_file.write('dex\t{}\n'.format(dex)) ...Then you can load them:
with open('character.txt') as character_file: for line in character_file: attribute, value = line.split() if attribute == 'str': str = int(value) ...Two pieces of advice: learn classes (there's a link to a tutorial in my signature, below) and upgrade to Python 3.6.
Main reason using 2.7 is that I have access to a book on 2.7. If I was to put this data into a class can I save it just as a class and then load it as a class? (I did OOP in Java years ago but on my first day in Python.)