Ad

How To Write A Result Of A Variable Type List In Logfile?

- 1 answer

I'm setting a code in python 2.7 where I have to write the result of a list variable in logfile

I tried logFile.write(.format(var))
also logFile.write.print(var)

var = []
logFile.write(var)
Ad

Answer

This can be achieved using the python's join() method:

logFile.write("\n".join(var))

Try this and tell me if this works.


Requesting old members to help me properly formulate the answer.

Ad
source: stackoverflow.com
Ad