昨天使用了当日23:59:59的时间戳。在网上搜了很多,基本80%都是粘贴复制的。不仅不能看,也不能用。老实说,这只是垃圾!浪费时间,真不知道这么烂的网站(C开头的烂网站),百度给这么高的权重!重新看了官方的datetime,发现实现起来很简单。我写的方法虽然不方便,但是比起网上80%的烂文章,这个至少管用!第一步引入datetime模块importdatetime第二步只获取当前日期的年月日转换成字符格式current_date=str(datetime.date.today()).split('-')#2022-08-31|['2022','08','31']第三步获取合并日23:59:59条件last_time={'year':int(current_date[0]),#参数只支持整形,你需要字符串转换位整形'month':int(current_date[1]),'day':int(current_date[2]),'hour':23,'minute':59,'second':59}#get23:59:59Timestamplast_time_stamp=int(datetime.datetime.today().replace(**last_time).timestamp())默认转换的时间戳小数点很长,我不能直接全部用withshaping去除int后的输出结果:1661961599正常输入的时间戳:1661961599.339121
