gpt4 book ai didi

python - 如何在 Jupyter Notebook 中计算分数(替换为变量值)?

转载 作者:行者123 更新时间:2023-12-01 01:15:04 53 4
gpt4 key购买 nike

我正在与 python markdown package 合作在 Jupyter 中,当我在 Markdown 单元格中使用变量时,我找不到在线评估变量的方法。

例如,我的代码单元将包含:

a = 1
b = 2

我使用 python markdown 的 markdown 单元应该是:

$\frac{{{a}}{{{b}}$

生产

enter image description here

有没有办法评估“a”和“b”,以便我可以将它们放入 LaTeX markdown 单元格中?我想使用 Jupyter 笔记本对报告进行逐步计算,因此在将笔记本写入 pdf 或 .tex 文件的过程中替换变量值至关重要。

我探索过pylatex ,但这似乎也没有使用分数的数学示例(仅矩阵和向量的类)。

最佳答案

您将需要this扩展名。

The Python Markdown extension allows displaying output produced by the current kernel in markdown cells. The extensions is basically agnostic to the kernel language, however most testing has been done using Python.

For example: If you set variable a in Python

a = 1.23

and write the following line in a markdown cell:

a is {{a}}

It will be displayed as:

a is 1.23

关于python - 如何在 Jupyter Notebook 中计算分数(替换为变量值)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54431451/

53 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com