我正在使用 Ipython Notebook 2
我在变量中有一个文件名,它动态计算位于当前目录中的文件的位置和文件名,我想将该变量插入到我的标记中以下载它
下面是代码:
result_file ="Revenue_per_city"+start_date+"_"+end_date+".xlsx
然后我的标记下载文件:
<a href= {{result_file}}> Click here to download the result</a>
但它没有按预期工作
我正在使用 Ipython Notebook 2
我在变量中有一个文件名,它动态计算位于当前目录中的文件的位置和文件名,我想将该变量插入到我的标记中以下载它
下面是代码:
result_file ="Revenue_per_city"+start_date+"_"+end_date+".xlsx
然后我的标记下载文件:
<a href= {{result_file}}> Click here to download the result</a>
但它没有按预期工作
您可以使用模块中的工具显示 HTML IPython.display:
HTML是将 HTML 表示为文本的对象display是一个显示对象的函数(如print, 但用于富媒体对象)例如:
from IPython.display import display, HTML
# create a string template for the HTML snippet
link_t = "<a href='{href}'> Click here to download the result</a>"
result_file = "Revenue_per_city" + start_date + "_" + end_date + ".xlsx"
# create HTML object, using the string template
html = HTML(link_t.format(href=result_file))
# display the HTML object to put the link on the page:
display(html)