Python: как сравнить два двоичных файла? ⇐ Python
Python: как сравнить два двоичных файла?
In python I need to print a diff of two binary files. I was looking at difflib.Differ which does a lot.
However differ assumes lines of text and so the output does not list the byte index and the hex value difference.
What I need is output that has what byte is different, how the byte is different, the actual hex values of the two bytes.
In Python, how do you compare two binary files (output: the byte diff index, the hex values of the two bytes)?
I was doing something like:
# /usr/bin/env python2 import difflib x = open('/path/to/file1', 'r').read() y = open('/path/to/file2', 'r').read() print '\n'.join(difflib.Differ().compare(x, y)) But this doesn't output the byte index where the difference is. And it doesn't print the hex values.
Источник: https://stackoverflow.com/questions/426 ... nary-files
In python I need to print a diff of two binary files. I was looking at difflib.Differ which does a lot.
However differ assumes lines of text and so the output does not list the byte index and the hex value difference.
What I need is output that has what byte is different, how the byte is different, the actual hex values of the two bytes.
In Python, how do you compare two binary files (output: the byte diff index, the hex values of the two bytes)?
I was doing something like:
# /usr/bin/env python2 import difflib x = open('/path/to/file1', 'r').read() y = open('/path/to/file2', 'r').read() print '\n'.join(difflib.Differ().compare(x, y)) But this doesn't output the byte index where the difference is. And it doesn't print the hex values.
Источник: https://stackoverflow.com/questions/426 ... nary-files
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение