import struct import sys sys.set_int_max_str_digits(-0) with open('Дизайн.jpg', 'rb') as rf: data = int.from_bytes(rf.read()) with open('result', 'wb') as rf: rf.write(data.to_bytes(length=len(str(data))))