Python Docx添加简单数学方程式的输出 [英] Python Docx add output of simple math equation

查看:89
本文介绍了Python Docx添加简单数学方程式的输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将简单数学方程式的输出添加到docx doc中?

How do I add the output of a simple math equation to my docx doc?

例如

math = 2+2

math

add_paragraph只能执行字符串,不能执行整数.有没有解决的办法?

add_paragraph can only do strings and not integers. Is there a work around for this?

p = document.add_paragraph(math)
document.save('doc.docx')

推荐答案

使用强制转换

math_string = str(math)
p = document.add_paragraph(math_string)
document.save('doc.docx')

这篇关于Python Docx添加简单数学方程式的输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆