how to read a file in python and write to a new file code example
Example 1: python append a file and read
f = open(filelocation/name, "a")
f.write("Now the file has more content!")
f.close()
f = open("C:/test/input.txt", "r")
print(f.read())
Example 2: python create unreadable save file
import hmac, pickle
pickled = pickle.dumps(data)
digest = hmac.new("some-shared-key", pickled,
digestmod=<my choice of hasher>
).hexdigest()
with open("some-file", "wb") as f:
print(digest, file=f)
print(pickled, file=f)