【问题标题】:Create a file download link to a dynamically generated file in Google Colab jupyter notebooks在 Google Colab jupyter notebooks 中为动态生成的文件创建文件下载链接
【发布时间】:2018-11-17 13:18:50
【问题描述】:

如何让 FileLink(filename) 在 Google Colab 中工作以生成下载链接?有比 FileLink 更好的方法吗?

现在这段代码会生成一个指向 localhost 的下载链接:

import pandas as pd
from IPython.display import FileLink, FileLinks

df = pd.DataFrame([[1,2,3],[4,5,6]])
df.to_csv('mydf.csv', index=False)
FileLink('mydf.csv')

作为输出生成的链接指向:https://localhost:8080/myfile.csv

如何让它指向正确的文件?

【问题讨论】:

    标签: jupyter google-colaboratory file-link


    【解决方案1】:

    试试:

    from google.colab import files
    files.download('mydf.csv')
    

    或者,更简单地说,使用左侧窗格中的文件浏览器。

    【讨论】:

    • 谢谢。它没有完全回答问题(如何在 colabra 中生成动态文件链接),但它解决了我的问题! :-)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多