30 lines
824 B
Python
30 lines
824 B
Python
# -*- coding: utf-8 -*-
|
|
# @Time : 2024/2/8 20:25
|
|
# @Author : len
|
|
# @File : 数据取反.py
|
|
# @Software: PyCharm
|
|
# @Comment :
|
|
|
|
def invert_hex_values(hex_values):
|
|
"""Invert a list of hexadecimal values."""
|
|
return [~value & 0xFF for value in hex_values]
|
|
|
|
# 原始数据
|
|
original_data = [
|
|
|
|
0x00, 0x00, 0x80, 0x01, 0xE0, 0x07, 0xF0, 0x0F, 0xF8, 0x1F, 0xFE, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF,
|
|
0xFE, 0x7F, 0xFE, 0x7F, 0xFC, 0x3F, 0xFC, 0x3F, 0xFC, 0x3F, 0xF8, 0x1F, 0xF8, 0x1F, 0x00, 0x00,
|
|
|
|
]
|
|
|
|
# 取反原始数据
|
|
inverted_data = invert_hex_values(original_data)
|
|
|
|
# 打印反转后的数据,移除引号,并按指定格式输出
|
|
print("Inverted Data:")
|
|
for i, byte in enumerate(inverted_data):
|
|
# 每行打印8个值
|
|
end = ", " if (i + 1) % 8 != 0 else ",\n"
|
|
print(f"0x{byte:02X}", end=end)
|
|
|