英文:
How to print all output in terminal to pdf when executing function in python?
问题
我有一个执行加法、减法、乘法和除法的函数。
def calculator(x, y):
print("Summation between", x, " & ", y, "is:", x + y)
print("Subtraction between", x, " & ", y, "is:", x - y)
print("Division between", x, " & ", y, "is:", x / y)
print("Multiplication between", x, " & ", y, "is:", x * y)
调用calculator
函数后,从终端获取输出如下:
Summation between 5 & 6 is: 11
Subtraction between 5 & 6 is: -1
Division between 5 & 6 is: 0.8333333333333334
Multiplication between 5 & 6 is: 30
我想将终端输出的所有值转换成PDF文件。感谢帮助!
英文:
For example, I have a function that performs addition, subtraction, multiplication and division.
def calculator(x,y):
print("Summation between", x, " & ",y, "is: ", x + y)
print("Subtraction between", x, " & ", y, "is: ", x - y)
print("Division between", x, " & ", y, "is: ", x / y)
print("Multiplication between", x, " & ", y, "is: ", x * y)
after calling the calculator function I get the output from the terminal, and output is:
Summation between 5 & 6 is: 11
Subtraction between 5 & 6 is: -1
Division between 5 & 6 is: 0.8333333333333334
Multiplication between 5 & 6 is: 30
I want to get all output value from terminal and convert to pdf file. Thank for help me!
答案1
得分: 1
Looks similar to the question here, with many answers for reference.
https://unix.stackexchange.com/questions/17406/how-to-convert-txt-to-pdf
英文:
Looks similar to the question here, with many answers for reference.
https://unix.stackexchange.com/questions/17406/how-to-convert-txt-to-pdf
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论