0

i have this kind of object:

lb = b'[5, "WEB9999", "Test 2", true]'

I try to convert it to a regular string for extract single values using:

ls = list(lb)

or

ls = list(str(lb))

but the results split every string in single chars

['b', "'", '[', '5', ',', ' ', '"', 'W', 'E', 'B', '9', '9', '9', '9', '"', ',', ' ', '"', 'T', 'e', 's', 't', ' ', '2', '"', ',', ' ', 't', 'r', 'u', 'e', ']', "'"]

How can I simply convert my bytes object in a python regular list for retrieving single value using mylist[3]?

Thanks in advance

Ray
  • 3,846
  • 7
  • 26
  • 35
Manuel Santi
  • 976
  • 10
  • 34
  • First convert the same to unicode by decoidng it to lb.decode('utf-8') then go for this link https://stackoverflow.com/questions/1894269/convert-string-representation-of-list-to-list – Ravinder Baid Sep 20 '18 at 11:50

1 Answers1

0

Try lb.decode()

by default I think it takes utf-8

EDIT

-Whomever downvoted is probably doing it for fun Here's a test img

-This is not a duplicated question, especially not related to 'Parse Json in Python'

lalam
  • 195
  • 1
  • 10