【发布时间】:2020-11-28 13:14:25
【问题描述】:
我正在使用下面的代码获取谷歌表格中的所有数据, 我想将所有这些数据写入 pdf 文件并下载。
import gspread
import sys
print(sys.path)
import os
#sys.path.append('/usr/lib/python3/dist-packages')
from oauth2client.service_account import ServiceAccountCredentials
scope = [
'https://www.googleapis.com/auth/spreadsheets',
'https://www.googleapis.com/auth/drive'
]
path = os.path.abspath('cred.json')
credentials=ServiceAccountCredentials.from_json_keyfile_name('cred.json',scope)
client=gspread.authorize(credentials)
sheet=client.open('xyz').sheet1
data=sheet.get_all_records()
print(data)
【问题讨论】:
-
好吗? Soooo....有什么问题?您当前的代码是否遇到问题?发生了什么问题?
-
您希望将
xyz的 Google 电子表格的第一个标签下载为 PDF 文件。我的理解正确吗? -
我的代码正在运行,是的,我想以 pdf 格式下载 xyz 表的所有数据,@Tanaike。你能告诉我我该怎么做。
-
感谢您的回复。从你的回复中,我建议了一个答案。你能确认一下吗?如果这不是您期望的结果,我深表歉意。
标签: python google-sheets-api gspread