Why can't I join this tuple in Python?

前端 未结 4 1868
不知归路
不知归路 2021-01-31 07:31
e = (\'ham\', 5, 1, \'bird\')
logfile.write(\',\'.join(e))

I have to join it so that I can write it into a text file.

4条回答
  •  醉酒成梦
    2021-01-31 08:04

    You might be better off simply converting the tuple to a list first:

    e = ('ham', 5, 1, 'bird') liste = list(e) ','.join(liste)

提交回复
热议问题