Manipulating binary data in Python

前端 未结 7 1331
旧时难觅i
旧时难觅i 2021-02-07 07:16

I am opening up a binary file like so:

file = open(\"test/test.x\", \'rb\')

and reading in lines to a list. Each line looks a little like:

7条回答
  •  孤城傲影
    2021-02-07 07:42

    You are trying to print the data converted to ASCII characters, which will not work.

    You can safely use any byte of the data. If you want to print it as a hexadecimal, look at the functions ord and hex/

提交回复
热议问题