1

I have a print that works perfectly to me since I use tabulate:

print(tabulate(query, headers= 'keys', tablefmt = 'psql'))

And I would like to export this print to a txt file just the way it looks in terminal.

Thanks for your support!

Berny
  • 113
  • 11

1 Answers1

1

Try in this way

print(tabulate(query, headers= 'keys', tablefmt = 'psql'), file=open("output.txt", "a"))
Evren
  • 4,147
  • 1
  • 9
  • 16