在此纪录自己练习的过程。
首先在你的google cloud platform 新增专案
再启用google drive、sheets api
新增凭证
名称自订,角色选project 编辑者
把金钥档放在你要的目录
python
我使用gspread这个库
import gspreadfrom oauth2client.service_account import ServiceAccountCredentialsscope = ['https://spreadsheets.google.com/feeds', 'https://www.googleapis.com/auth/drive']credentials = ServiceAccountCredentials.from_json_keyfile_name('yourkey.json', scope)gc = gspread.authorize(credentials)wks = gc.open("your sheets").sheet1
记得要把你的key档里面client_email加入共用者到你的试算表
print(wks.get_all_records())
这样就完成读取google sheets了!