Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python tupel from string

from ast import literal_eval as make_tuple

food_tuple_str = "('pizza', 'pasta', 'fish')"
food_tuple = make_tuple(food_tuple_str)
print(food_tuple)  # ('pizza', 'pasta', 'fish')
print(type(food_tuple))  # <class 'tuple'>
 
PREVIOUS NEXT
Tagged: #python #tupel #string
ADD COMMENT
Topic
Name
4+5 =