Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
给定字符串: aa0a051c1400,我将如何提取 just05或1c? 我正在阅读串行响应,我需要检查十六进制数据的片段,以破译在这个初始数据包之后有多少数据从管道中传出。
aa0a051c1400
05
1c
只需按索引解析字符串即可。如果要按字符索引解析:
from binascii import hexlify, unhexlify def get_hex(stream, idx): return hexlify(unhexlify(stream)[idx]) get_hex('aa0a051c1400', 0) 'aa'