【发布时间】:2018-04-30 00:07:14
【问题描述】:
我正在尝试创建一个简单的 Jupyter Notebook here。在我的代码中,我必须加载一个文件 file.txt 放在 home 的 /data 目录中
data/file.txt
代码
open('data/file.txt', 'r')
或
open('~/data/file.txt', 'r')
我遇到了一个错误
FileNotFoundError: [Errno 2] 没有这样的文件或目录:'~/data/file.txt'
【问题讨论】:
-
@snakecharmerb 我怎样才能得到
myusername。我尝试从 url 获取用户名,但它不起作用。https://hub.mybinder.org/user/ipython-ipython-in-depth-xxxx/notebooks/binder/Index.ipynb#。路径/home/ipython-ipython-in-depth-xxxx/data/file.txt