字节格式的时间数据不匹配
time data in byte not matching format
last_appended_row_timestamp = datetime.strptime(str(last_appended_row_timestamp), "%Y-%m-%d %H:%M:%S")
这里的代码会产生一个错误,说
ValueError: time data "b'2019-12-08 23:59:59'" does not match format
'%Y-%m-%d %H:%M:%S'.
b'2019-12-08 23:59:59'
是byte,将byte放入str()
,就得到了结果。问题是什么??提前致谢。
因为:
str(b'2')
>>> "b'2'"
因此您需要更改代码,如下所示:
datetime.strptime(last_appended_row_timestamp.decode('u8'), "%Y-%m-%d %H:%M:%S")
last_appended_row_timestamp = datetime.strptime(str(last_appended_row_timestamp), "%Y-%m-%d %H:%M:%S")
这里的代码会产生一个错误,说
ValueError: time data "b'2019-12-08 23:59:59'" does not match format '%Y-%m-%d %H:%M:%S'.
b'2019-12-08 23:59:59'
是byte,将byte放入str()
,就得到了结果。问题是什么??提前致谢。
因为:
str(b'2')
>>> "b'2'"
因此您需要更改代码,如下所示:
datetime.strptime(last_appended_row_timestamp.decode('u8'), "%Y-%m-%d %H:%M:%S")