I would like to save strings into text files while ordering them, I need to do it by score (from 1-10) and these can be inputed in any random order. Is there a way to seek out strings in text files and then use the .seek() function there?
I have it to save in the text file as "(Name) has a score of (Score)" I just use f.write to input this into a text file
f = open("Saves.txt", "r")
Score = str(Score)
O = (f.read())
f.close()
f = open("Saves.txt","w")
f.seek(0)
Saving = (O) + " " + (Name) + " " +(Last_Name) + " has a score of " + (Score) + "\n"
f.write((Saving))
f.close()
I'd try a memory mapped file. It gives you string and file semantics. For example, you can use the
re
library with mmap.