I have a tuple full of bytes and i need to convert these bytes into one single utf-8 string, how can i do that?
data = tuple([0, 4, 4, 6, 1, 53])
print(data as utf-8 string?)
data = bytes(tuple([0, 4, 4, 6, 1, 53])).decode('utf-8')
output:
'\x00\x04\x04\x06\x015'
functions used:
bytes() - convert an iterable to a bytes like object
decode('utf-8') - decode bytes to utf8
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.