importxlrdimportxlwtimportsysMARGE_INPUT_FILE_NAME_STR=u"input.xls"MARGE_OUTPUT_FILE_NAME_STR=u"output.xls"MARGE_SHEET1_NAME_STR=u"sheet1"MARGE_SHEET_NAME_STR=u"核算项目明...
import xlrd
import xlwt
import sys
MARGE_INPUT_FILE_NAME_STR = u"input.xls"
MARGE_OUTPUT_FILE_NAME_STR = u"output.xls"
MARGE_SHEET1_NAME_STR = u"sheet1"
MARGE_SHEET_NAME_STR = u"核算项目明细表"
def open_excel(filePath=MARGE_INPUT_FILE_NAME_STR):
"读取xls文件数据"
data = xlrd.open_workbook(filePath)
try:
data = xlrd.open_workbook(filePath)
return data
except Exception,exce:
print str(exce)
if __name__ == "__main__":
if len(sys.argv) >= 2:
for index in range(1,len(sys.argv)):
getInfos(filePath=sys.argv[index], sheetName=u"核算项目明细表", nameList=nameList, resule=result)
output(filePath=u"结果表.xls", sheetName=u"结果表", nameList=nameList, resule=result, sheetList=sheetList)
else:
print "请输入要处理的数据文件名称和文件路径"
sys.argv[index] 上面的方法怎么获取输入的文件名
求例子
展开