2016-06-19 70 views

回答

0

從這個example,你可以打開一個電子表格的標題或網址。

例子:

def open(self, title): 
     """Opens a spreadsheet, returning a :class:`~gspread.Spreadsheet` instance. 
     :param title: A title of a spreadsheet. 
     If there's more than one spreadsheet with same title the first one 
     will be opened. 
     :raises gspread.SpreadsheetNotFound: if no spreadsheet with 
              specified `title` is found. 
     >>> c = gspread.Client(auth=('[email protected]', 'qwertypassword')) 
     >>> c.login() 
     >>> c.open('My fancy spreadsheet') 
     """ 
     feed = self.get_spreadsheets_feed() 

     for elem in feed.findall(_ns('entry')): 
      elem_title = elem.find(_ns('title')).text 
      if elem_title.strip() == title: 
       return Spreadsheet(self, elem) 
     else: 
      raise SpreadsheetNotFound 

您還可以檢查這些鏈接:

0

您可以使用pygsheets,一個Python庫爲谷歌牀單API V4 。

import pygsheets 

gc = pygsheets.authorize() 

# Open spreadsheet by title 
sh = gc.open('my new ssheet') 
相關問題