0

Let's say I have this table: hello = ["hello","world"]

Now I convert it to a string: hellostring = str(hello)

And now I want to convert it back to a table. How can I do this?

1 Answers1

1

You can use ast.literal_eval:

from ast import literal_eval
literal_eval(hellostring)

input: hellostring = "['hello', 'world']"

output: ['hello', 'world']

mozway
  • 81,317
  • 8
  • 19
  • 49