Cmag Cmag - 1 year ago 55
Python Question

How to convert a tuple to a string in Python?

After a MySQL select statement, I am left with the following:

set([('',), ('',), ('',), ('',), ('',), ('',), ('',), ('',)])

What I would like to have is a

emaillist = "\n".join(queryresult)

to in the end, have a string:

What would be the proper way to convert this nested tuple into string?

Answer Source

As long as you're sure you have just one element per tuple:

'\n'.join(elem[0] for elem in queryresult)