python - 从桌面(我的 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
如果它已经在我的桌面上,为什么我会收到此错误?
解决方案
由于我正在开发一个基于 Web 的在线交互式开发环境,因此我需要做的就是将文档上传到仪表板(/home/jovyan/binder/
),只需转到菜单栏 File>Open。
我已经在那里上传了我的文档,现在它在路径更改时可以正常工作(
/home/jovyan/binder/PrototypeIncidentAudit.xlsx'
)
推荐阅读
- javascript - 在力气泡图上添加/删除气泡的问题
- r - R中的查找表
- ios - Firebase 身份验证未按预期工作。用户正在登录主屏幕或注册页面
- r - 数据表 R:合并来自多个 data.table 的选定列
- autodesk-forge - 缺少 Edit2D 事件的字符串是什么?
- kubernetes - 为主管道和底层管道保留相同的 jenkins 代理 pod
- python - 用里面的字符串对列表进行排序
- java - 在反应流中对项目进行分组
- python - 为什么 python 从备用路径导入共享对象时会抛出未定义符号错误?
- html - Google HTML 服务 - 评估模板并保留评论