I want to know how to write and read variables from a text file. So if I'm doing a game, for example, I'll be able to save the player's progress.
In pseudo code:
variable = 1
# write to text file that variable = 1
# close program
# open program
variable
# Then IDLE should output 1
If you can help me out I would really appreciate it!
dict,list,str,int,float,bool,Noneyou can use thejsonmodule. If you need to store more complex types you can use thepicklemodule, with the caveat that "thepicklemodule is not secure against erroneous or maliciously constructed data," so you should "never unpickle data received from an untrusted or unauthenticated source."