使用sheet.insert\u row()通过python api在gsheet中设置日期格式

2024-06-07 19:12:58 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一份数据清单

record = ['Tuesday','2018-08-29'] 

我试着把它通过

sheet.insert_row(record,index)

我成功地在我的gsheet上接收到了它,但问题是,在gsheet上我得到的日期是字符串,我不能在上面应用任何公式。我尝试将字符串转换为日期格式

record[1] = datetime.datetime.strptime(record[1], '%Y-%m-%d')

但在使用insert时,行给了我一个错误

TypeError: Object of type datetime is not JSON serializable

Tags: 数据字符串datetimeindex格式错误recordsheet

热门问题