if __name__ == '__main__': # 时间戳 import time seconds = time.time() # 时间戳转换为字符串 print(time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(seconds))) # 字符串转换为时间戳 print(time.mktime(time.strptime("2018-08-07", "%Y-%m-%d")))
if len(df) > 0: # 字符串转换为时间戳 x = list(df['日期']) x1 = [time.mktime(time.strptime(c, "%Y-%m-%d")) for c in x] df['日期时间戳'] = x1 df.sort_values(by='日期时间戳', inplace=True, ascending=True)
发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/205721.html原文链接:https://javaforall.net
