python 输出latex字符串为数学公式

导入Latex包

from IPython.display import Latex

书写Latex字符串

s1 = r"$frac{{partial {}}}{{partial {}}}$".format(1, 2)

注意在使用format时,要输出 { } 这两个符号比较麻烦,我们需要使用{{}}才能输出{}符号,这样我们可以将需要在{}的公式片段写在{{}}里面。

输出结果:

Latex(r"$frac{{partial {}}}{{partial {}}}$".format(1, 2))

清澈的爱,只为中国
原文地址:https://www.cnblogs.com/dan-baishucaizi/p/14352402.html