繁体   English   中英

如何在 python 中打印数学?

[英]How to print math in python?

I would like to print math in python with print(), as it is possible to do in plot's label with matplotlib (see this link for all the math you can write with matplotlib https://matplotlib.org/tutorials/text/mathtext .html ) 这可能吗? 我尝试了以下方法(如在 matplotlib 中):

print(r'$\Delta v$:', delta)

例如打印一个希腊 delta,但它不起作用(因为它不是 matplotlib 函数),它显示: $\Delta v$: delta

您实际上可以在 Python 中毫无问题地打印字符。 只需通过 Google 搜索找到相关的 unicode 字符,然后将它们复制/粘贴到您的打印语句中。

print('Δ')
print('α')

不,通常不可能使用print function 执行此操作 - 它只是将纯文本输出到标准 output。 matplotlib可以将数学文本渲染为例如 plot 标题,因为它的目标是生成的图像。

正如 Kurt Kline 所说,您可以显示简单的字符,但不能显示和符号或上标之类的复杂表达式。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM