如何通过googlesheets API访问googlesheets中的不同选项卡?

2024-05-14 23:59:27 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试使用googledrive/Sheets API从googledrive读取工作表。我想知道如何在不同的标签间导航。在

The tab is the circled part, (ignore the other stuff) (忽略其他内容,这是一张随机图片,展示了标签是什么。)

基本上,我想做的是能够访问其他选项卡并阅读其中的文本。每个选项卡的格式相同。我已经能够从第一个标签开始阅读,并希望对其他人也一样。在

这是我的代码:

import gspread
from oauth2client.service_account import ServiceAccountCredentials
import pprint


# Use credentials to interact with the Google Drive API
scope = ['https://spreadsheets.google.com/feeds',
         'https://www.googleapis.com/auth/drive']
credentials = ServiceAccountCredentials.from_json_keyfile_name(
    'foo', scope)
client = gspread.authorize(credentials)

# Opening the first sheet
sheet = client.open("Resume Data").sheet1

# Prints the code in a nicer format
pp = pprint.PrettyPrinter()


# Extract and print all of the values
list_of_resumes = sheet.get_all_records()

# Printing
pp.pprint(list_of_resumes)

Tags: ofthefromhttpsimportcomapi标签
1条回答
网友
1楼 · 发布于 2024-05-14 23:59:27
  • 要从除第一个索引的工作表以外的工作表中获取值。在
  • 您希望使用gspread实现这一点。在
  • 您已经能够获取并放置电子表格的值。在

如果我的理解是正确的,那这次修改怎么样?在

发件人:

sheet = client.open("Resume Data").sheet1

收件人:

^{pr2}$

注:

  • 如果要使用索引选择工作表,请使用sheet = spreadsheet.get_worksheet(1)。这意味着要选择第二个索引的表。在

参考:

相关问题 更多 >

    热门问题