我使用这个python脚本采取从浦API响应: http://docs.progresso.apiary.io/#reference/behaviour/behaviour-events-collection/get-behaviour-events蟒蛇gspread从人体效应初探更新多个细胞
from urllib2 import Request, urlopen
import smtplib import gspread
from oauth2client.service_account import ServiceAccountCredentialseaders = {
'Authorization': 'Bearer [CURRENT_TOKEN]'
}
request = Request('https://private-anon-ae5edf57e7-progresso.apiary-
mock.com/BMEvents/?Behaviour=new', headers=headers)
response_body = urlopen(request).read()
scope = ['https://spreadsheets.google.com/feeds']
credentials = ServiceAccountCredentials.from_json_keyfile_name('ProgressoAPI-
2f6ecaa6635c.json', scope)
gc = gspread.authorize(credentials)
wks = gc.open("Progresso Test").sheet1
wks.clear()
cell_list = wks.range('A1:H20')
for cell in cell_list:
cell.value = response_body
wks.update_cells(cell_list)
我知道cell.value =响应主体是错误的,我不知道我如何才能做到 - 我被卡住了。
它出现在这样的每一个细胞: “{ ”“ BehaviourEntryId” “:13798177, ”“ LearnerId” “:245277, ”“ LearnerCode” “: ”“ 2009-0080” “ ” “RegGroup”“:”“U6-RWE”“, ”“Behavior”“:”“Negative”“, ”“IncidentDate”“:”“2017-02-07”“, ”“Subject”“: “”“”“”“”位置“”:“”CLS“”, “ “:null, ”“Assignee”“:”“DiRo”“, ”“Status”“:”“Completed”“, ”“详细信息“”:“类别”“:”“CLatt”“,” “”严重性“”:“”S2“”, “”点“ “:0 }, { ”“ 类别”, “: ”“ CL””, “” 类型 “”: “” CLBEH “”, “” 严重性 “”: “” S2 “”, “”点 “”:2 } ], “” 意见 “”:[ { “” BehaviourEntryCommentId “”:5648278, “” 机密 “”:真实, “” 评论 “”: “” 问去去了厕所,去了最远的一个地方,为了浪费时间。输入法 “” }, { “” BehaviourEntryCommentId “”:5648279, “” 机密 “”:假的, “” 评论 “”: “地板上” 稚贝胶去 “” }, { “ “BehaviourEntryCommentId” “:5648280, ”“ 机密” “:假的, ”“ 评论” “: ”“ 很粗鲁员工的memeber”” } ], “” 操作 “”: “” HTO “”, “”ISO“” “ }”
如何将文本与单元格范围内的文本分开并批量更新?
哪来这种添加到代码的最佳地点?我加了这个,并且一直给出无效的语法错误。 –
我不太确定不知道整个代码。语法错误在哪里?导入应该始终放在代码的顶部。 – tehtea