2017-04-07 53 views
-1

您好,我是新開發的web開發人員,並且一直在使用python來創建我的web應用程序。這裏是我的代碼:成功克隆和安裝pyexcel-xlsx,但導入時出現語法錯誤

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它得到一個語法錯誤,我該如何解決這個問題?

回答

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) 
相關問題