Feb-17-2017, 07:38 PM
I'm just starting to learn Python 3.6 and this will be my first program. (I have coded in Basic and C about 20 years ago)
Does Python 3.x have a built-in byte string compare function or will I need to code it myself?
My task is:
1. Read a file as binary into 'mydata'.
2. Get the length of mydata. ..... mydataLength = len(mydata)
3. Search for a 5 byte string (like 43 2A 7E 59 C6)
........ If found, skip ahead 52 bytes and change the contents of that byte.
........ Note: The searching will be done byte-by-byte using indexing. ..... mydata[indexcount]
4. Repeat step 3 until the end of the binary string where ..... indexcount => mydataLength.
If there is a built-in byte string compare function, then please provide a link to it so I can learn how to use it.
Just asking here before I start coding a byte compare function myself, to save the extra work if a built-in compare function already exists. I did do a Google search but could not find a specific answer to my question.
Thanks.
Does Python 3.x have a built-in byte string compare function or will I need to code it myself?
My task is:
1. Read a file as binary into 'mydata'.
2. Get the length of mydata. ..... mydataLength = len(mydata)
3. Search for a 5 byte string (like 43 2A 7E 59 C6)
........ If found, skip ahead 52 bytes and change the contents of that byte.
........ Note: The searching will be done byte-by-byte using indexing. ..... mydata[indexcount]
4. Repeat step 3 until the end of the binary string where ..... indexcount => mydataLength.
If there is a built-in byte string compare function, then please provide a link to it so I can learn how to use it.
Just asking here before I start coding a byte compare function myself, to save the extra work if a built-in compare function already exists. I did do a Google search but could not find a specific answer to my question.
Thanks.