Python: Converting from Tuple to String?

前端 未结 3 1765
情话喂你
情话喂你 2020-12-19 02:42

let\'s say that I have string:

    s = \"Tuple: \"

and Tuple (stored in a variable named tup):

    (2, a, 5)
3条回答
  •  甜味超标
    2020-12-19 02:58

    >>> tup = (2, "a", 5)
    >>> s = "Tuple: {}".format(tup)
    >>> s
    "Tuple: (2, 'a', 5)"
    

提交回复
热议问题