Reputation: 107
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?
Upvotes: 2
Views: 10308
Reputation: 95993
You can use int
to convert to the corresponding integer:
struct.pack('<Q', int('0x401a12', base=16))
Upvotes: 2