zcwch 发表于 2020-12-18 15:49

python能读取wps保存的表格吗

各位高手:在学习python的过程中,操作wps保存的表格,出现错误,pyhon不能处理wps文档吗?
C:\Users\wang\PycharmProjects\pythonProject2\venv\Scripts\python.exe C:/Users/wang/PycharmProjects/pythonProject2/1.py
Traceback (most recent call last):
File "C:/Users/wang/PycharmProjects/pythonProject2/1.py", line 2, in <module>
    workbook = xlrd.open_workbook('E:/lc/2.xlsx')
File "C:\Users\wang\PycharmProjects\pythonProject2\venv\lib\site-packages\xlrd\__init__.py", line 166, in open_workbook
    file_format = inspect_format(filename, file_contents)
File "C:\Users\wang\PycharmProjects\pythonProject2\venv\lib\site-packages\xlrd\__init__.py", line 60, in inspect_format
    with open(path, "rb") as f:
FileNotFoundError: No such file or directory: 'E:/lc/2.xlsx'

公子如玉世无双 发表于 2020-12-18 15:53

把代码附上来啊,不然怎么知道你哪里出问题

zcwch 发表于 2020-12-18 15:53

import xlrd
workbook = xlrd.open_workbook('E:/lc/2.xlsx')
print(workbook.sheet_names())

yuan-0.0 发表于 2020-12-18 15:57

skr 发表于 2020-12-18 16:02

路径不对吧 检查一下`E:/lc/2.xlsx`这个路径

Louis_cllc 发表于 2020-12-18 16:11

你的路径不对头, / 应该改成 \

thepoy 发表于 2020-12-18 16:59

不存在的话是不是要先创建此文件

sougou 发表于 2020-12-18 17:01

import xlrd
workbook = xlrd.open_workbook('E:\lc\2.xlsx')
print(workbook.sheet_names())

Hui_jiang 发表于 2020-12-18 17:12

换pandas

zcwch 发表于 2020-12-18 17:53

简单几行代码,路径写法绝对正确,通过反复实验,wps保存的表格不能读取。
页: [1] 2
查看完整版本: python能读取wps保存的表格吗