org模式,源代码块,结果

2024-10-02 12:30:28 发布

您现在位置:Python中文网/ 问答频道 /正文

在org模式的beamer表示中,我想使用python或{}源代码块来处理电子表格中的数据。我知道怎么做。在

会有一个结果向量,我需要在不同的幻灯片上得到单独的向量元素。有没有一种方法可以分解结果向量,这样我就不需要每次都重新计算电子表格了?也许让python只将向量存储为变量,然后使用内联python调用来提取值?在

示例:

#+name: calculation
#+begin_src python :result value
return [1, 2, 3]
#+end_src

*** Slide one
I calculated <how to insert :calculationresult[0]>?
- some 
- content

*** Slide two
I calculated <how to insert :calculationresult[1]>?
- more
- content

Tags: to数据orgsrc源代码模式content向量
1条回答
网友
1楼 · 发布于 2024-10-02 12:30:28

只是随便看看文档,所以我找到了以下解决方案:

  • 在会话模式下计算代码块内的结果
  • 在使用相同会话的内联代码调用中提取结果
#+name: calc
#+begin_src python :session :results output :exports none
  myvec = [1, 2, 3]
#+end_src

#+RESULTS: calc


* Page 1

I got number src_python[:session]{myvec[1]}

相关问题 更多 >

    热门问题