【发布时间】:2020-08-15 22:01:58
【问题描述】:
我一直在关注 Tim 关于 Google Sheets API 的教程 (https://www.youtube.com/watch?v=cnPlKLEGR7E)
当我到达sheet.insert_row(insertRow, 9) 行时,它显示了一个错误,
所有其他的东西都工作得很好。
重要的是,蒂姆没有遇到同样的问题。
代码:
import gspread
from oauth2client.service_account import ServiceAccountCredentials
from pprint import pprint
scope = ["https://spreadsheets.google.com/feeds",'https://www.googleapis.com/auth/spreadsheets',"https://www.googleapis.com/auth/drive.file","https://www.googleapis.com/auth/drive"]
creds = ServiceAccountCredentials.from_json_keyfile_name("Raz.json", scope)
client = gspread.authorize(creds)
sheet = client.open("RandomRaz").sheet1
row = sheet.row_values(3)
col = sheet.col_values(2)
cell = sheet.cell(1,2).value
insertRow = ["Test#123", "Url!"]
sheet.insert_row(insertRow, 9)
pprint(len(col))
错误:
Traceback (most recent call last):
File "/Users/#######/PycharmProjects/pythonProject/x.py", line 19, in <module>
sheet.insert_row(insertRow, 9)
AttributeError: 'Worksheet' object has no attribute 'insert_row'
【问题讨论】:
-
你用的是什么版本的gspread?
标签: python google-sheets google-api