簡體   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