I want to write the print statement as well as the returned statement from the code into a pdf file. In other words, I want to write an exact terminal-output into a PDF file. Could anyone help me how to get this?
import fpdf
def oops():
print('hello')
return('V')
def data():
return oops()
pdf = fpdf.FPDF(format = 'A4')
pdf.add_page()
pdf.set_font("Arial")
pdf.cell(10, 10, data())
pdf.output("2.pdf")
I want to write the exact terminal-output into a PDF file. Could anyone help me how to get this?
The expected output in the PDF file is
hello
V