converting string to tuple in python

前端 未结 5 1082
我寻月下人不归
我寻月下人不归 2021-01-22 02:12

I have a string returnd from a software like \"(\'mono\')\" from that I needed to convert string to tuple .

that I was thinking using ast.literal_eval

5条回答
  •  花落未央
    2021-01-22 03:10

    Convert string to tuple? Just apply tuple:

    >>> tuple('(mono)')
    ('(', 'm', 'o', 'n', 'o', ')')
    

    Now it's a tuple.

提交回复
热议问题