TypeError: ‘instancemethod‘ object has no attribute ‘__getitem__‘
生活随笔
收集整理的這篇文章主要介紹了
TypeError: ‘instancemethod‘ object has no attribute ‘__getitem__‘
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
報錯的具體原因如下:
代碼如下
# -*- coding: utf-8 -*-
import openpyxl
import sys
reload(sys)
sys.setdefaultencoding("utf-8")
table = openpyxl.load_workbook("/home/hly/me.xlsx")
print table.get_sheet_by_name["Sheet1"]
最后fabian是使用get_sheet_by_name獲取Sheet1 的問題引起的,應該是小括號() 而不是中括號[]
修改后報錯處理了
# -*- coding: utf-8 -*-
import openpyxl
import sys
reload(sys)
sys.setdefaultencoding("utf-8")
table = openpyxl.load_workbook("/home/hly/me.xlsx")
print table.get_sheet_by_name("Sheet1")
?
總結
以上是生活随笔為你收集整理的TypeError: ‘instancemethod‘ object has no attribute ‘__getitem__‘的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: python -如何查看已经安装xlrd
- 下一篇: 救赎的作者是谁啊?