Is there any way to save to progress of a Python Program onto an I.P. Address or Harddrive? Like if you enter '5' into a program that multiplies your number by 3 and save it, your saved number would be 'x' when you reopen the file. I need help! :)
Norbert X 42 Junior Poster in Training
Recommended Answers
Jump to PostYeah there sure is
#use the current directory or absolute path f = open("File.txt",'w') #write mode 'w' answer = 5*3 #make a string, only stings can be added to files answer = str(answer) f.write(answer) f.close() #then open it back up o = open("File.txt",'r') #read mode 'r' print …
Jump to PostYou can use pickle, that is useful because it saves the data as it is, so if you have a class you can save the class, and then you load it and it is exactly the same as it was when you saved it.
For that you would need …
Jump to Post#first: class NorbertQuest(object): #every function goes in here #every variable is renamed self.variable #so if i was "health" it would be "self.health" #then you can get rid of all the global this and global that #because using "self" means that is can be accessed all over the …
All 9 Replies
Norbert X 42 Junior Poster in Training
lllllIllIlllI 178 Veteran Poster
Gribouillis 1,391 Programming Explorer Team Colleague
Norbert X 42 Junior Poster in Training
lllllIllIlllI 178 Veteran Poster
Norbert X 42 Junior Poster in Training
lllllIllIlllI 178 Veteran Poster
Norbert X 42 Junior Poster in Training

leegeorg07
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.