0

我的程序无法处理我从 Excel 电子表格中提取的货币对象时遇到问题。除了更改货币的错误之外,代码运行并执行我想要的操作。这是我执行代码时出现的错误。有这方面的建议吗?

FutureWarning:货币对象将很快更改,因此使用了 decimal.Decimal 实例。(设置 pythoncom.future_currency现在获取这些对象。)

这是我正在运行的代码:

import sys, os, win32com.client, glob
from win32com.client import constants
xl = Excel_Document()

headerlist = ['STUDYDES','STUDYDES2','EVENTTYPE','AssessmentSOLUTIONTYPE','AssessmenFDNS-TERMINATION','SOLUTIONTYPE','FDNS-TERMINATION','GROUP','SCENARIO','ProviderOASISReservation','CustomerName','RequestedStart_Date']

ListofData = []
Data = []
counter = 1
xlslist = glob.glob('*tblFacilityLog*.xls')



for xls in xlslist:
    headers = {}
    sortedvalues = []
    output = {}
    print 'Opening Workbook: ',xls
    xl.openWorkbook(xls)

    sheetdata = xl.getSheetData('tblAllFacilityLog')
    xl.closeWorkbook()

    for row in sheetdata:
        sortedvalues = []
        for header in headerlist:
            if header in sheetdata[0]:
                output[header] = row[sheetdata[0].index(header)]
            else:
                output[header] = "'None'"

        for header in headerlist:
            sortedvalues.append(output[header])

        Data.append(sortedvalues)

    ListofData.append(Data)

print 'Building Workbook'
print len(Data)
print len(ListofData)

xl.addWorkbook()
xl.addWorksheet("tblFacilityLog9")
xl.selectSheet("tblFacilityLog9")


beginrow = 1
lastrow = beginrow + len(Data)
#xl.pasteData(headerlist, startcol = beginrow, startrow = beginrow, endcol = len(headerlist), endrow = 1)

for Data in ListofData:
    xl.pasteData(Data, startcol = 1, startrow = 1, endcol = len(headerlist), endrow = lastrow)

xl.saveWorkbook("CombinedLog")
xl.closeWorkbook()
xl.closeApp()
4

1 回答 1

0

此错误意味着:如果它现在工作,请忽略警告。如果它你不会更新 pythoncom 模块,那么你没有问题。如果您想尽快使用更新版本的 pythoncom,那么您可以通过以下方式尝试新功能

import pythoncom
pythoncom.__future_currency__ = True # I guess it is True

这是我对错误的理解。

于 2014-02-11T21:32:18.170 回答