简体   繁体   中英

Python converting hex string to hex little endian byte code

I'm trying to do this

pack("<Q", 0x401a12)

It works as it is, but I need pack() to take string hex code

addr = "0x401a12" # some hex from dump
pack("<Q", addr)

Any help?

您可以使用int转换为相应的整数:

struct.pack('<Q', int('0x401a12', base=16))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM