Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python bytes to dict

# credit to the Stack Overflow user in the source linnk
# Python3

import ast

byte_str = b"{'one': 1, 'two': 2}"
dict_str = byte_str.decode("UTF-8")
my_data = ast.literal_eval(dict_str)

print(repr(my_data))
>>> {'one': 1, 'two': 2}
Source by www.google.com #
 
PREVIOUS NEXT
Tagged: #python #bytes #dict
ADD COMMENT
Topic
Name
6+4 =