AttributeError:'str'对象没有属性'parse'

我正在学习Python,第一次尝试使用pandas。 我有一个目录,大约有50个excel工作簿,我试图将它们合并为一个。

import openpyxl import pandas as pd import numpy as np import glob import os import sys #path = "\\\\mtrjesmith\\Service Parts Photography Project\\STERISForms" files = os.listdir("\\\\mtrjesmith\\Service Parts Photography Project\\STERISForms") outf = "C:\\Python27\\Scripts\\steris_forms\\compiled.xls", "w+b" #print(files) frame = [x.parse(x.sheet_names[0], header=None,index_col=None) for x in files] frame[1:] = [df[1:] for df in frame[1:]] combined = pd.concat(frame) combined.to_excel("C:\\Python27\\Scripts\\steris_forms\\compiled.xls", "w+b", header=False, index=False) 

我得到以下错误:

 Traceback (most recent call last): File "C:\Python27\Scripts\steris_forms.py", line 18, in <module> frame = [x.parse(x.sheet_names[0], header=None,index_col=None) for x in files] AttributeError: 'str' object has no attribute 'parse' 

我能做些什么来解决这个问题? 任何其他反馈将不胜感激。

尝试这个:

 frame = [pd.read_excel(x, header=None, index_col=None) for x in files]