How to get tuple from a tuple string / How to convert a tuple string to tuple in Python
For example, we would like to get a tuple (1,2,3,4,5) out of a string - '(1,2,3,4,5)' in python. We can use literal_eval from ast as follows:
from ast import literal_eval s = '(1,2,3,4,5)' t = literal_eval(s)
Newer Post
Older Post
Home