我无法通过g-spread列出所有工作表

问题描述 投票:0回答:1

第98行上的“ navigate_sheet函数”第99行未显示工作表列表

我不太确定尝试什么

https://pastebin.com/Mzy3R5cn

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:“工作表”对象没有属性“工作表””

python gspread
1个回答
0
投票

我认为您忘记了初始化sheet数据成员。

© www.soinside.com 2019 - 2024. All rights reserved.