第98行的功能“ navigate_sheet”上 第99行不显示工作表列表
我不太确定要尝试什么
class InputData:
def __init__(self):
# use creds to create a client to interact with the Google Drive API
self.scope = ['https://spreadsheets.google.com/feeds',
'https://www.googleapis.com/auth/drive']
self.creds = ServiceAccountCredentials.from_json_keyfile_name('client_secret.json', self.scope)
self.client = gspread.authorize(self.creds)
self.sheet = ""
self.error = "[!] There was a critical error that broke the program!"
def navigate_sheet(self):
worksheet_list = self.sheet.worksheets()
print(worksheet_list)
预期结果:
显示工作表列表实际结果:“ AttributeError: “工作表”对象没有属性“工作表””
答案 0 :(得分:0)
我认为您忘记了初始化sheet
数据成员。
https://gspread.readthedocs.io/en/latest/user-guide.html#opening-a-spreadsheet
此链接可以帮助您初始化工作表成员