即使文件成功上传,我也不确定为什么我可以在Jupyter笔记本中看到上传文件的前5行:
import io
from IPython.display import display
import fileupload
def _upload():
_upload_widget = fileupload.FileUploadWidget()
def _cb(change):
decoded = io.StringIO(change['owner'].data.decode('utf-8'))
filename = change['owner'].filename
print('Uploaded `{}` ({:.2f} kB)'.format(
filename, len(decoded.read()) / 2 **10))
_upload_widget.observe(_cb, names='data')
display(_upload_widget)
uploaded_file = _upload()
Uploaded `plot.R` (3.00 kB)
%%bash
pwd
head -5 uploaded_file
head -5 "/home/jalal/plot.R"
head -5 plot.R
%%bash
pwd
head -5 uploaded_file
head -5 "/home/jalal/plot.R"
head -5 plot.R
/home/jalal
head: cannot open ‘uploaded_file’ for reading: No such file or directory
head: cannot open ‘/home/jalal/plot.R’ for reading: No such file or directory
head: cannot open ‘plot.R’ for reading: No such file or directory
我也尝试过这个:
_upload
然后
head -5 filename
我收到此错误:
head: cannot open ‘filename’ for reading: No such file or directory