私の文字列は次のようになります:
"('f', ('d', ('a', 'b')), 'g')"
それをタプルに変換したい。どのようにそれを行うことができます...私は樹状図を描く際にそれを使用します
編集:追加の説明:私のコードと出力(プリント):
print type(myString) # <type 'str'>
print myString #('f',('d',('a','b')),'g')
myString = ast.literal_eval(myString)
print type(myString) #<type 'tuple'>
print myString #('f', ('d', ('a', 'b')), 'g')
for tuple in myString: #f
print tuple #('d', ('a', 'b'))
#g