成功克隆并安装了pyexcel-xlsx,但导入时出现语法错误

时间:2017-04-07 23:41:21

标签: python flask

您好我是Web开发的新手,并且一直在使用python来制作我的网络应用程序。这是我的代码:

def forecastvalues():
    import fileinput
    import csv
    from pyexcel_xlsx import get_data
    xlsxfile= "test.xlsx"
    import json

    with open(xlsxfile, "rb") as f:
    content = f.read()
    r = pe.get_book(file_type="xlsx", file_content=content, start_row=1)

    for i in records:
        columns = sheet.row[i]
         for j in columns:
             rem = sheet.column[0]
             sold1 = sheet.column[1]
             sold2  = sheet.column[2]

    return '<h1>Result: %s</h1>' % result

我正确安装了pyexcel,但是当我导入pyexcel时出现语法错误,我该如何解决?

1 个答案:

答案 0 :(得分:0)

content = f.read()不是缩进的,也不是它的后续行。

应该是:

with open(xlsxfile, "rb") as f:
    content = f.read()
    r = pe.get_book(file_type="xlsx", file_content=content, start_row=1)