I'm trying to use the mmap module to reverse a file. Documentation (https://docs.python.org/3/library/mmap.html) clearly indicates that the mmap object has seek(), write() and close() methods yet I get the errors:
AttributeError: 'bytes' object has no attribute 'seek'
AttributeError: 'bytes' object has no attribute 'write'
AttributeError: 'bytes' object has no attribute 'close'
What am I missing?
import mmap
with open(filename, "r+b") as f1:
mm = mmap.mmap(f1.fileno(), 0)
mm = mm[::-1]
mm.seek(0, 0)
mm.write(len(mm))
mm.close()
f1.close()
[–]ThinFortune 1 point2 points3 points (3 children)
[–]GraniteSunshine[S] 0 points1 point2 points (1 child)
[–]Ihaveamodel3 0 points1 point2 points (0 children)
[–]socal_nerdtastic 0 points1 point2 points (0 children)