模块' gspread.worksheet'没有属性' update_cell'
我的代码:
import gspread
from gspread import worksheet
from oauth2client.service_account import ServiceAccountCredentials
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("keys.json", scope)
client = gspread.authorize(creds)
spreadsheet = client.open("ackerwaldundwiese")
worksheet.update_cell(1, 2, "car")
输出
Traceback (most recent call last):
File "C:\Users\mm\PycharmProjects\pythonProject1\ddf.py", line 8, in <module>
worksheet.update_cell(1, 2, "car")
AttributeError: module 'gspread.worksheet' has no attribute 'update_cell'
我正在使用Pycharm 2022.1.1(社区版)Windows 10
My code:
import gspread
from gspread import worksheet
from oauth2client.service_account import ServiceAccountCredentials
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("keys.json", scope)
client = gspread.authorize(creds)
spreadsheet = client.open("ackerwaldundwiese")
worksheet.update_cell(1, 2, "car")
Output
Traceback (most recent call last):
File "C:\Users\mm\PycharmProjects\pythonProject1\ddf.py", line 8, in <module>
worksheet.update_cell(1, 2, "car")
AttributeError: module 'gspread.worksheet' has no attribute 'update_cell'
I'm using PyCharm 2022.1.1 (Community Edition) windows 10
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
嗨,在访问工作表之前,您必须先检索它。
在您的情况下,应该像以下方式一样:
注意:如果您需要获得不同的表,则将返回第一张纸,使用方法 get_worksheet
从代码中删除此行
您应该 这很敏感,因此 w orksheet对象不存在,但 w orksheet确实存在。
Hi before accessing a worksheet you must retrieve it first.
In you situation it should be sometlike this:
Note: this will return the first sheet, if you need to get a different sheet use the method get_worksheet
You should remove this line from your code:
You don't need to import the
Worksheet
object and it is case sensitive so the worksheet object does not exists but the Worksheet does.