[英]How to generate a pdf report with math/calculus results
I'm trying for the first time generate a pdf report with math results, and I'm asking for help here because I allready searched online and didn´t found anything relatable.我第一次尝试生成带有数学结果的 pdf 报告,我在这里寻求帮助,因为我已经在网上搜索并没有找到任何相关的东西。 I tried adpating a code that I found and I added the variable that I want to export to the pdf, in this case "C", however didn´t work out.
我尝试修改找到的代码,然后添加了要导出到 pdf 的变量,在本例中为“C”,但没有成功。 Any idea?
任何想法?
Code:代码:
from fpdf import FPDF
pdf = FPDF()
a = 1
b = 1
C = a+b
pdf.add_page()
pdf.set_font("Arial", size = 25)
# create a cell
pdf.cell(200, 10, txt = "a+b =", C,
ln = 1, align = 'C')
pdf.output("a.pdf")
您没有正确连接.. Python 使用+
并且您需要使用str()
将整数转换为字符串
txt = "a+b ="+str(C),
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.