【发布时间】:2014-08-10 19:20:33
【问题描述】:
我在运行我的模块 gasprop 时收到此错误。我不明白错误的含义以及如何解决它:
import gasprop
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "gasprop.py", line 13, in <module>
sheet = wb.Sheets("Input1")
File "C:\Python27\lib\site-packages\win32com\gen_py\00020813-0000-0000-C000-000000000046x0x1x6\Sheets.py", line 113, in __call__
ret = self._oleobj_.InvokeTypes(0, LCID, 2, (9, 0), ((12, 1),),Index
pywintypes.com_error: (-2147352567, 'Exception occurred.', (0, None, None, None, 0, -2147352565), None)
这是我的模块 gasprop:
import win32com.client, os
xl = win32com.client.gencache.EnsureDispatch("Excel.Application")
thisdir = os.getcwd()
wb = xl.Workbooks.Open(thisdir+"/Input1.xlsx")
sheet = wb.Sheets("Input1")
......
def megaverify(self):
listtr,listp=[],[]
for i in range(16):
tr=float(sheet.Range("D"+str(5+i)).Value)
p=float(sheet.Range("C"+str(5+i)).Value)
listtr.append(tr);listp.append(p)
return tr, p
【问题讨论】:
-
我使用了 xlrd 并且现在可以使用,不过我想知道这里的问题
标签: python excel operating-system