I want to convert to a hex string (ex: 0xAD4
) hex number, then add For that code <0> 0x200 and then want to print that code as 0x
as that string.
I tried the first step:
str (int (item [1] [: - 2]), 16))
but the printed value is not a decimal string in a hex formatted string (in 0x format) (I want to print the end result as 0x
)
[: - 2]
to remove the last 00 from that number items [1]
in 0x <
Try it out: Pre> hex_str = "0xAD4" hex_int = int (hex_str , 16)) New_in = hex_int + 0x200 print hex (new_int)
If you do not like 0x
in the beginning, then the last line
Change with Print HEX (NewMant) [2:]
Comments
Post a Comment