首页 > 解决方案 > 从桌面(我的 PC)中读取文件 .xlsx,该文件已经存在,具有相同的扩展名。#JupyterLab 基于 Web 的交互式开发环境

问题描述

代码:

import xlrd
    loc = input(r'Enter the path of your file: ')
    print(loc)
    #loc="C:\Users\anuj.masand\Desktop\PrototypeIncidentAudit.xlsx"
    assert os.path.exists(loc), "I did not find the file at, "+str(loc)

    wb = xlrd.open_workbook(loc)
    Print("I got it")

错误:

AssertionError                            Traceback (most recent call last)
<ipython-input-16-4ab769c51fe8> in <module>
      3 print(loc)
      4 #loc="C:\Users\anuj.masand\Desktop\PrototypeIncidentAudit.xlsx"
----> 5 assert os.path.exists(loc), "I did not find the file at, "+str(loc)
      6 
      7 wb = xlrd.open_workbook(loc)

AssertionError: I did not find the file at, C:\Users\anuj.masand\Desktop\PrototypeIncidentAudit.xlsx

如果它已经在我的桌面上,为什么我会收到此错误?

标签: pythonjupyter-notebookjupyter-lab

解决方案


由于我正在开发一个基于 Web 的在线交互式开发环境,因此我需要做的就是将文档上传到仪表板(/home/jovyan/binder/),只需转到菜单栏 File>Open。

我已经在那里上传了我的文档,现在它在路径更改时可以正常工作(/home/jovyan/binder/PrototypeIncidentAudit.xlsx'


推荐阅读