无法使用xlrd在python中打开excel文件
我正在使用python 2.7和最新的xlrd软件包。
import xlrd xfile = xlrd.open_workbook("random_stuff.xlsx");
上面的代码给了我一个错误,说:
un(shallow)copyable object of type <type 'Element'>
并带我到一个文件名为cElementTree.py
其中包含:
# Wrapper module for _elementtree from _elementtree import *
什么是错误,我根本不明白。 我相当新的python。 我一个月前开始学习。 编辑:使用位置的方法:
import xlrd file_location = "C:\Users\Tanmay\Documents\Visual Studio 2015\Projects\PythonApplication1\PythonApplication1\random_stuff.xlsx" xfile = xlrd.open_workbook(file_location , r)
给出以下错误:
[Errno 22] invalid mode ('rb') or filename: 'C:\\Users\\Tanmay\\Documents\\Visual Studio 2015\\Projects\\PythonApplication1\\PythonApplication1\random_stuff.xlsx'
你可以使用原始string吗?
file_location = r"C:\Users\Tanmay\Documents\Visual Studio 2015\Projects\PythonApplication1\PythonApplication1\random_stuff.xlsx"