I am looking to see if there is a way to automatically do a 1s compliment or flip the bits in a file or files. I have managed to open a file in binary using the syntax "file=open('001.a','rb')" and then searching through stack overflow found a while loop to iterate.
When I assign a variable to the read portion of the file so for eg. a = file.read() and then do type on a[1] it appears as type 'str'.
I am confused as If I opened this file as a binary file then shouldn't everything be shown in 1's and 0's.
Sorry am really new to programming and am totally lost. I have searched through and looked at a lot of examples but none of them appear to give a complete solution and picking and mixing code from different posts is not working as I keep getting type errors. I tried using struct but just do not understand the syntax or what is it supposed to achieve.
I would think that I need to convert that string to a binary of 1's and 0s and then somehow flip all 0's to 1 and 1 to 0's but it seems to be easier said then done.
a[:10] '\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff'
Thanks