I am reading file in binary mode using python and it is working perfectly. I tried to update the content and the save it into a new file. The code's below:
def main():
f = open("inputFile", "rb")
myFile = f.read()
outFile = myFile
for i in range(0, len(myFile)):
d1 = myFile[i] + 1
outFile[i] = d1
f2 = open("otFile", "wb")
f2.write(outFile)
f2.close()
The error is:
outFile[i] = d1
TypeError: 'bytes' object does not support item assignment
I tried
outFile[i] = bytes(d1)
I've got this error:
TypeError: 'bytes' object does not support item assignment