python - 使用 python 导出 Sympy 乳胶
问题描述
我正在尝试使用以下 python 代码
已解决(@TheFool 提示):通过将 latex() 放入 print 函数,它可以工作。
from sympy import *
from sympy.printing.mathml import mathml
init_printing(use_unicode=True) # allow LaTeX printing
# independent variables
x, y, z = symbols('x y z', real = True)
# parameters
nu, rho = symbols('nu rho', real = True, constant = True, positive = True)
# dependent variables
u, v, w = symbols('u v w', real = True, cls = Function)
print(latex(diff(u(x,y,z),x)))
输出看起来像
'\\frac{\\partial}{\\partial x} u{\\left (x,y,z \\right )}'
.
如何删除输出开头和结尾处的额外反斜杠和引号?
解决方案
您是否尝试过包括:..?
from sympy import init_printing
init_printing()
查看 sympy 打印选项的文档。看起来 init_printing 是正确输出的方法。
推荐阅读
- django - Django - 是否可以只翻译一些模型(管理表单)?
- python - 绘制一个包含所有 1 和 0 的数据帧,其中 x 代替 1,空白为 0
- algorithm - 从离散概率分布算法中采样
- python - 执行时额外的空白 tkinter GUI
- java - 试图在 IntelliJ IDEA 中创建 jar 可执行文件
- python - 使用 OR 工具将取货和交付的成本降至最低
- excel - 检查所有工作表的真实值,在 VBA 中获得一个带有“无差异”的消息框
- c++ - 将 1 个浮点数从数组传递到每个顶点的顶点着色器
- mysql - 在 AWS EC2 上使用 mongosqld 时如何查看通过 AWS DocumentDB 托管的 MongoDB
- c# - 如何绘制图像轮廓内的内容,但将其他所有内容留空?