- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我需要将“767f440128e1a00a”十六进制数据转换为打包的 EBCDIC 字符串。我希望所有 result
结果都变成一个字符串,但 python 给出 Unicode 错误 UnicodeDecodeError: 'utf-8' codec can't Decode byte 0xe1 inposition 0: Unexpected end of data
s='767f440128e1a00a'
output = []
DDF = [1]
distance = 0
for y in range (1,len(s[2:])):
for x in DDF:
if s[2:][distance:x*2+distance]!='':
output.append(s[2:][distance:x*2+distance])
else:
continue
distance += x*2
print(output)
final=[]
result=''
bytearrya=[]
for x in output:
result=(str(bytearray.fromhex(x).decode()))
x = codecs.decode(x, "hex")
final.append(x)
最佳答案
这是基于 Python byte representation of a hex string that is EBCDIC 的代码提到“根据this,需要使用‘cp500’进行解码”
Codec / Aliases / Languages
cp500 / EBCDIC-CP-BE, EBCDIC-CP-CH, IBM500 / Western Europe
my_string_in_hex = '767f440128e1a00a'
my_bytes = bytearray.fromhex(my_string_in_hex)
print(my_bytes)
my_string = my_bytes.decode('cp500')
print(my_string)
输出:
关于python - HexString 到打包的 EBCDIC 字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58364186/
在python操作数据内容时,多数情况下可能遇到下面3种类型的数据处理: hexstring 如:'1c532145697a8b6f' str 如:'\x1c\x53\x21\x45\x69\x
我正在尝试将 BitArray 转换为十六进制字符串 我的测试 BitArray 是“0000001010000000”,它应该以十六进制返回“02 80” 尝试了以下方法: BitArray b =
我需要将“767f440128e1a00a”十六进制数据转换为打包的 EBCDIC 字符串。我希望所有 result 结果都变成一个字符串,但 python 给出 Unicode 错误 Unicode
我有一个 32 位十六进制值,我希望将其转换为整数。 给定十六进制字符串 C71C5E00,以下方法都提供以下错误: java.lang.NumberFormatException: For inpu
我在字符串示例中有一个数据源 HexString = "72AE" 我想把它转换成字节并存储到字节数组中 bytearray = [72, AE] //UInt8 我知道我可以做到这一点 let h
关闭。这个问题需要details or clarity .它目前不接受答案。 想改进这个问题吗? 通过 editing this post 添加细节并澄清问题. 关闭 7 年前。 Improve t
关闭。这个问题是opinion-based 。目前不接受答案。 想要改进这个问题吗?更新问题,以便 editing this post 可以用事实和引文来回答它。 . 已关闭 3 年前。 Improv
下面的代码采用一个十六进制字符串(每个字节都表示为其对应的十六进制值)将其转换为 unsigned char * 缓冲区,然后再转换回十六进制字符串。此代码正在测试从 unsigned char* 缓
在搜索互联网后,我设法创建了一个 C# 类来获取 FileTimeUTC 十六进制字符串。 public class HexHelper { public static string GetU
HashCalc在顶部有一个名为“数据格式”的字段,我将其切换为“HexString”,然后在数据字段中输入 9a 的测试值。我对其运行 SHA-1 哈希,答案是:13cba177bcfad90e7b
Bouncy CaSTLe SCrypt Java API。 byte[] sCryptHash = SCrypt.generate(plaintextPassword.getBytes(), sal
您好,我有一个十六进制字符串,我需要将它转换成 jpg 图像,请解释一下我是怎么做到的。我需要将这个十六进制字符串转换成 jpg 图像,我正在尝试,但没有成功. String hex="ff d8
我想使用 AES 算法。 我用这个功能就可以了 void SubBytes(char *SArr[4][4]){ int r,c; char xlook[2];char ylook[2]; char
我需要将 float 值转换为十六进制字符串,然后再转换回来。在线IEEE 754 Converter允许我这样做。这是我实现转换的尝试: unsafe static void Main(string
我是一名优秀的程序员,十分优秀!