python时间戳和时间字符串的转换
2024-10-09 05:37:00
# -*- coding: utf-8 -*-
# date=2020/3/27
import time
import uuid def getTimestamp_1770():
now_1770 = round(time.time() - 1770) * 1000
return now_1770 def getTimestamp(num):
# 1800为30分钟,1740为29分钟
now_1770 = round(time.time() - num) * 1000
return now_1770 def getTimestamp_1700():
now_1700 = round(time.time() - 1700) * 1000
return now_1700 def getTimestamp_1690():
now_1710 = round(time.time() - 1690) * 1000
return now_1710 def getTimestamp_1680():
now_1720 = round(time.time() - 1680) * 1000
return now_1720 def timeToTimestamp(timeStr):
# 先转换为时间数组
timeArray = time.strptime(timeStr, "%Y-%m-%d %H:%M:%S")
# 转换为时间戳
timeStamp = int(time.mktime(timeArray)) * 1000
# print(timeStamp)
return timeStamp def timestampToTime(timeStamp):
timeArray = time.localtime(timeStamp / 1000)
timeStamp = time.strftime("%Y-%m-%d %H:%M:%S", timeArray)
# print(timeStamp)
return timeStamp if __name__ == '__main__':
# a = timeToTimestamp('2020-03-27 13:46:20')
#
# a = getTimestamp_1700()
# p = timestampToTime(a)
# print(p)
print(uuid.uuid1())
pass
最新文章
- [转]python 常用类库!
- [mobile开发碎碎念]手机页面上显示PDF文件
- the usage of map.put
- phonegap+html5开发app的一些总结
- ext 金额大写
- Caption,Text,WindowText的区别——TControl也有FText,是为了模拟一个窗口
- Tcpdump命令行 与 GUI Wireshark
- Web.Config文件中添加数据库配置文件
- Introduction to Guid ( globally unique identifier )
- 在 Arch 下编译 OpenWRT cmcurl 问题与解决方案
- js单元测试
- Qt5.7.0移植到4412
- 项目构建之maven篇:5.仓库及nexus创建私服-2
- Java的GUI设计中如何跨界面传值
- C#+AE 判断点是否在面内的方法
- using 释放内存的写法
- sparkuser is not in the sudoers file. This incident will be reported.
- WebService客户端调用的几种方式
- MySQL-ALTER TABLE命令学习[20180503]
- oracle11g之Oracle体系结构(理论基础知识)