1
我試圖讓Google Sheets API在Python 3的電子表格中返回SERIAL_NUMBER時間。下面是我的代碼用得到它(不包括憑證功能:如何在Python的Google Sheets API中使用SERIAL_NUMBER時間
http = credentials.authorize(httplib2.Http())
discoveryUrl = ('https://sheets.googleapis.com/$discovery/rest?'
'version=v4')
service = discovery.build('sheets', 'v4', http=http,
discoveryServiceUrl=discoveryUrl)
spreadsheetId = 'REDACTED'
rangeNames = ['Sheet1!A2:E','Sheet1!F2:F']
result = service.spreadsheets().values().batchGet(
spreadsheetId=spreadsheetId, ranges=rangeNames, dateTimeRenderOption='SERIAL_NUMBER').execute()
print(result.get('valueRanges'))
正如你所看到的,我通過它的dateTimeRenderOption,但它總是返回一個格式化字符串,如「2016年9月7日」,而不是串行的編號如何獲得序列號?