You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#to read
reader = shelve.open('textfile.txt')
text = reader['textfile']
reader.close()
Also shelve may be favorable since user's can't access the text file easily. Neither mac not windows have a built in reader for the type of text file it creates.
you can also use and call the following functions
def shelvewrite(textfilename,towrite): #write to text file
textfilenametxt = textfilename + '.txt'
writer = shelve.open(str(textfilenametxt))
writer[str(textfilename)] = towrite
writer.close()
def shelveread(textfilename): # read form text file
textfilenametxt = textfilename + '.txt'
reader = shelve.open(str(textfilenametxt))
text = reader[str(textfilename)]
reader.close()
return text
def shelveappend(textfilename, toappend): #append to text file
textfilenametxt = textfilename + '.txt'
read = shelveread(textfilename)
toappend = (read, toappend)
shelvewrite(textfilename, toappend)
No description provided.
The text was updated successfully, but these errors were encountered: