[string] encode() >> [bytes]
[bytes] hex() >> [hex_string]
[hex_string] fromhex() >> [bytes]
[bytes] decode() >> [string]
1) bytes dan encode()
k = bytes("4d", "utf-8")
setara dengan
j = "4d".encode()
>> k = j = b"4d"
2) hex()
k = bytes("a4d", "utf-8")
> k = b'a4d'
m = k.hex()
> m = '613464'
3) fromhex() dan decode()
n = bytes.fromhex(m)
> n = b'a4d'
p = n.decode("utf-8")
> p = 'a4d'
UTF Notes:
encoded
j = "4d".encode("utf-8")
>> j = b'4d'
j = "4d".encode("utf-16")
>> j = b'\xff\xfe4\x00d\x00'
No comments:
Post a Comment
Terima kasih