我想導入一個EXCEL文件,但代碼有一些問題。幫助!AttributeError:'模塊'對象沒有屬性'open_openwork'
回答
的原因是因爲xlrd
模塊沒有在它open_openwork()
功能。
你可能會尋找功能是open_workbook()
:
open_workbook(...)
- Open a spreadsheet file for data extraction.
加有任何關於在文檔模式 - 通過提供第二個參數設置的日誌文件(打開的文件對象,該消息將被讀)。
所以不是:
bk = xlrd.open_openwork("fname","rb")
做:
bk = xlrd.open_workbook("fname")
我修補它。但是,還是有一些新的錯誤。回溯(最近呼叫最後一個): 文件「D:\ pdf-ex \ test2.py」,第3行,在
@wangling:這個告訴我的不多。將代碼發佈到某處(ideone.com?codepad.com?pastebin.com?)並告訴我哪一行不是。 3在這個文件中。 – Tadeck
進口xlrd 進口SYS FNAME = 「d:/pdf-ex/exc.xlsx」 BK = xlrd.open_openwork(其中 「fname」) shxrange =範圍(bk.nsheets) SH = bk.sheet_by_name(「Sheet 1中「) NROWS = sh.nrows NCOLS = sh.ncols 打印 「NROWS%d,%NCOLS d」 %(NROWS,NCOLS) CELL_VALUE = sh.cell_value(1,1) 打印CELL_VALUE row_list = [] 我在範圍內(1,nrows): row_data = sh.row_values(i) row_list.append(row_data) – wangling
- 1. AttributeError:'模塊'對象沒有屬性'openssl_md_meth_names'
- 2. AttributeError:'模塊'對象沒有屬性'openSPI'
- 3. AttributeError:'模塊'對象沒有屬性'get_frontal_face_detector'
- 4. AttributeError:'模塊'對象沒有屬性'merge_all_summaries'
- 5. AttributeError:'模塊'對象沒有屬性'ensure_future'
- 6. AttributeError:'模塊'對象沒有屬性'maketrans'
- 7. AttributeError:「'模塊'對象沒有屬性'ARRAY'」
- 8. AttributeError:'模塊'對象沒有屬性'WebSocketApp'
- 9. AttributeError:'模塊'對象沒有屬性'SFrame'
- 10. AttributeError:'模塊'對象沒有屬性'Fieldstorage'
- 11. attributeerror'模塊'對象沒有屬性'openfile'
- 12. AttributeError:'模塊'對象沒有'pin'屬性
- 13. AttributeError:'模塊'對象沒有屬性'pydebug'
- 14. AttributeError:'模塊'對象沒有屬性'MathField'
- 15. AttributeError:'模塊'對象沒有屬性'VERSION_STRING'
- 16. AttributeError:'模塊'對象沒有屬性'imread'
- 17. AttributeError:'模塊'對象沒有屬性'QueryFrame'
- 18. AttributeError:'模塊'對象沒有屬性'IntegerRangeField'
- 19. AttributeError:'模塊'對象沒有屬性'setup_graph'
- 20. AttributeError:'模塊'對象沒有屬性'MibVariable'
- 21. AttributeError:'模塊'對象沒有屬性'calWin'
- 22. AttributeError:'模塊'對象沒有屬性'x'
- 23. AttributeError:'模塊'對象沒有屬性'newperson'
- 24. AttributeError:'模塊'對象沒有屬性'audio_fadein'
- 25. Django,AttributeError:'模塊'對象沒有屬性
- 26. AttributeError:'模塊'對象沒有屬性'cv'
- 27. AttributeError:'模塊'對象沒有'load'屬性
- 28. GNU Radio OOT模塊AttributeError:'模塊'對象沒有屬性'MME_cpp'
- 29. AttributeError的:「模塊」對象有沒有屬性「模型」
- 30. 模式模塊共軛:AttributeError:'int'對象沒有屬性'lower'
問題是什麼?你是否收到語法錯誤或運行時錯誤,或者結果不正確? – Levon
對不起。剛纔,我給出了錯誤的代碼。實際上,「.open_openwork」應該是「.open_workbook」。 – wangling
@王玲:是的,正如我所建議的。刪除或接受;) – Tadeck