2017-10-08 72 views
0

我在这里https://developers.google.com/sheets/api/samples/writing下谷歌API的说明和遇到问题 与此块:Python的谷歌表麻烦写表

PUT https://sheets.googleapis.com/v4/spreadsheets/spreadsheets/d/\ 
    spreadsheetId/values/sheet1!A1:D5?valueInputOption=USER_ENTERED 
    values = { 
    "range": "'Main'!A1:D5", 
    "majorDimension": "ROWS", 
    "values": [ 
    ["Item", "Cost", "Stocked", "Ship Date"], 
    ["Wheel", "$20.50", "4", "3/1/2016"], #new row 
    ["Door", "$15", "2", "3/15/2016"], 
    ["Engine", "$100", "1", "30/20/2016"], 
    ["Totals", "=SUM(B2:B4)", "=SUM(C2:C4)", "=MAX(D2:D4)"] 
    ], 
} 

which gives PUT https://sheets.googleapis.com/v4/spreadsheets/\ 
spreadsheets/d/spreadsheetId/values/\ 
sheet1!A1:D5?\valueInputOption=USER_ENTERED 
     ^
SyntaxError: invalid syntax 

This is copied directly from the API documentation. Help! What is wrong? 
Thanks. 
+0

哪里是Python代码,使这个“PUT ......”?没有它也无能为力。 – glenfant

+0

这不是python代码。有[另一页(https://developers.google.com/sheets/api/guides/values#writing),让蟒蛇API。 – roganjosh

+0

绝对不是python代码。请参阅https://developers.google.com/sheets/api/quickstart/python上的说明以开始使用。 – swatchai

回答

0

writing guide告诉你使用:

https://sheets.googleapis.com/v4/spreadsheets/spreadsheetId/values/Sheet1!A1:D5?valueInputOption=USER_ENTERED 

你另一方面使用的是:

https://sheets.googleapis.com/v4/spreadsheets/spreadsheets/d/\ 
    spreadsheetId/values/sheet1!A1:D5?valueInputOption=USER_ENTERED 

URL的外观不一样。您的网址中存在不需要的'\'字符。