-3

I am sending data between python socket connection. The data is an array and I am sending it in blocks of each line. When the data comes in it looks like this:

data = '[1,0,1]'

I want to convert this back into array form so I can then add it back into my master array that is being sent over. Any idea how I can convert this string back into an array.

user9015687
  • 37
  • 2
  • 5

1 Answers1

3
import json

data = '[1,0,1]'

data = json.loads(data)

Out:

[1, 0, 1]
Brendan Martin
  • 561
  • 6
  • 17