-1

I have a string

s = '[ 1 , 2 , 3]'

how to create a list from s?

Padraic Cunningham
  • 168,988
  • 22
  • 228
  • 312
palazzo train
  • 3,027
  • 1
  • 16
  • 39

1 Answers1

2

You can use the json module:

import json
s = '[1, 2, 3]'
json_as_list = json.loads(s)
Chedy2149
  • 2,501
  • 3
  • 30
  • 52