在我的Jupyter笔记本中,我希望能够有可点击的链接,这些链接可以把你带到同一个笔记本的特定部分,也可以带到另一个笔记本的特定部分。这个是可能的吗?
发布于 2018-04-08 20:14:41
要在同一笔记本中创建内部可点击链接,请执行以下操作:
第1步:创建链接
[To some Internal Section](#section_id)第2步:创建目的地
<a id='section_id'></a>若要在一个笔记本中创建链接并在另一个笔记本中创建目标,请执行以下操作。
第1步:创建链接
[To Some Internal Section](another_notebook.ipynb#section_id2)第2步:创建目的地
<a id='section_id2'></a>如果笔记本位于当前工作目录中的文件夹中:
[To Some Internal Section](TestFolder/another_notebook.ipynb#section_id3)发布于 2018-09-30 13:58:31
对于任何使用Google Colaboratory的人
文件内链接:
单击右上角要链接到链接的单元格,单击省略号(...),然后单击Link to cell
[Section 5](#hashtag_suffix)))开始标记中的链接
链接到其他文件
与上面类似;而不是复制完整的单元格链接
发布于 2021-12-07 12:20:43
基本上,您输入超链接的标题,然后将链接复制到剪贴板,并将其粘贴到您正在编写内容菜单的markdown单元格中。这将为您节省几次点击和时间。为此,需要安装并导入pyperclip库,以便能够将超链接保存到剪贴板:
要在同一jupyter笔记本上创建指向另一部分的超链接,请执行以下操作:
import pyperclip as pc
link_title = input('Enter hyperlink title:')
dashed_title = link_title.replace(" ", "-")
link = ('[{}](#{})'.format(link_title, dashed_title))
pc.copy(link)复制到剪贴板的示例结果:
[Section 1](#Section-1)

作为函数:
def link_menu(hyperlink_title):
import pyperclip as pc
dashed_title = hyperlink_title.replace(" ", "-")
link = ('[{}](#{})'.format(hyperlink_title, dashed_title))
return pc.copy(link)调用函数,将想要作为超链接的字符串作为参数传递:
link_menu('Section 1')要制作指向不同Jupyter笔记本的其他部分的超链接,请执行以下操作:
import pyperclip as pc
link_title = input('Enter hyperlink title:')
external_notebook_name = input('Enter external notebook name:')
dashed_title = link_title.replace(" ", "-")
link = ('[{}]({}.ipynb#{})'.format(link_title, external_notebook_name, dashed_title))
pc.copy(link)复制到剪贴板的示例结果:
[Section 9](another_notebook.ipynb#Section-9)作为函数:
def link_menu_other(hyperlink_title, name_external_notebook):
import pyperclip as pc
dashed_title = hyperlink_title.replace(" ", "-")
link = ('[{}]({}.ipynb#{})'.format(hyperlink_title, name_external_notebook, dashed_title))
return pc.copy(link)调用函数,传递两个字符串作为参数,第一个是超链接的名称,第二个是外部jupyter笔记本的名称
link_menu_other('Section 10 to another notebook', 'other_notebook')https://stackoverflow.com/questions/49535664
复制相似问题