| 12345678910111213141516171819202122232425262728293031323334353637383940414243 | #!/usr/bin/python3import sysimport codecsimport tracebackimport requestsimport reimport pandas as pdimport randomimport urllibimport jsonimport gspreadimport datetimefrom gspread_pandas import Spread, Clientfrom oauth2client.service_account import ServiceAccountCredentialsimport osdef save_sheet(df,filename,tabname,startpos='A1'):    scope = ['https://spreadsheets.google.com/feeds',            'https://www.googleapis.com/auth/drive']    credentials = ServiceAccountCredentials.from_json_keyfile_name('c:\\keys\\innnews-d27b01472ba2.json', scope)    gc = gspread.authorize(credentials)    spread = Spread(filename,creds=credentials)    spread.df_to_sheet(df, index=False, sheet=tabname, start=startpos, replace=False)def get_sheets(filename):    scope = ['https://spreadsheets.google.com/feeds',            'https://www.googleapis.com/auth/drive']    credentials = ServiceAccountCredentials.from_json_keyfile_name('c:\\keys\\innnews-d27b01472ba2.json', scope)    gc = gspread.authorize(credentials)#    files=gc.list_spreadsheet_files()#    print(files)    spread = Spread(filename,creds=credentials)    for ws in spread.sheets:        print(ws.title)get_sheets('引新聞xSEO團隊共用表單')#    spread.df_to_sheet(df, index=False, sheet=tabname, start=startpos, replace=False)#
 |