Python - convert list of tuples to string

后端 未结 7 1464
执笔经年
执笔经年 2020-12-05 10:50

Which is the most pythonic way to convert a list of tuples to string?

I have:

[(1,2), (3,4)]

and I want:

\"(1,2), (         


        
7条回答
  •  我在风中等你
    2020-12-05 11:11

    You can try something like this (see also on ideone.com):

    myList = [(1,2),(3,4)]
    print ",".join("(%s,%s)" % tup for tup in myList)
    # (1,2),(3,4)
    

提交回复
热议问题