Writing a list of tuples to a text file in Python

后端 未结 6 769
执笔经年
执笔经年 2021-01-05 14:11

I have a list of tuples in the format:

(\"some string\", \"string symbol\", some number)

For example, (\"Apples\", \"=\", 10).

6条回答
  •  遥遥无期
    2021-01-05 14:52

    >>> data= ("Apples", "=", 10)
    >>> print " ".join(map(str, data))
    Apples = 10
    

    Easy. Map the tuple/list to strings, then join them with " ".

提交回复
热议问题