# -*- 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时间戳和时间字符串的转换的更多相关文章

  1. Python时间戳与时间字符串互相转换实例代码

    #设a为字符串import timea = "2011-09-28 10:00:00" #中间过程,一般都需要将字符串转化为时间数组time.strptime(a,'%Y-%m-% ...

  2. Python 时间戳与时间字符串互相转

    #设a为字符串 import time a = "2011-09-28 10:00:00" #中间过程,一般都需要将字符串转化为时间数组 time.strptime(a,'%Y-% ...

  3. python 时间戳和时间格式互相转换

    #!/usr/bin/python3 # -*- coding: utf-8 -* import time def str_to_stamp(): # 转换显示格式 time1 = time.strp ...

  4. JS时间戳与时间字符串之间的相互转换

    时间字符串 转 时间戳 /** * 时间字符串 转 时间戳 * @param {String} time_str 时间字符串(格式"2014-07-10 10:21:12") * ...

  5. Python技巧——list与字符串互相转换

    Python技巧——list与字符串互相转换   在Python的编程中,经常会涉及到字符串与list之间的转换问题,下面就将两者之间的转换做一个梳理. 1.字符串转换成list 命令:list() ...

  6. mysql时间操作(时间差和时间戳和时间字符串的互转)

    mysql时间操作(时间差和时间戳和时间字符串的互转) 两个时间差: MySQL datediff(date1,date2):两个日期相减 date1 - date2,返回天数. select dat ...

  7. (转)golang获取当前时间、时间戳和时间字符串及它们之间的相互转换

    原文连接: https://blog.csdn.net/skh2015java/article/details/70051512 1.获取当前时间 currentTime:=time.Now() // ...

  8. Python技巧—list与字符串互相转换

    Python技巧-list与字符串互相转换 在Python的编程中,经常会涉及到字符串与list之间的转换问题,下面就将两者之间的转换做一个梳理. 1.list转换成字符串 命令:list() 例子: ...

  9. Python的time(时间戳与时间字符串互相转化)

    strptime("string format")字符串如"20130512000000"格式的 输入处理函数 localtime(float a)时间戳的输入 ...

随机推荐

  1. webpack4.x开发环境配置

    写这篇文章的初衷在于,虽然网络上关于webpack的教程不少,但是大多已经过时,由于webpack版本更新后许多操作变化很大,很多教程的经验已经不适合.当我们使用npm安装webpack时,若不指定w ...

  2. unittest 中的方法调用时报错 ValueError: no such test method in <class 'mytestcase.MyTestCase'>: runTest

    1.调用unittest中的方法时报错: ValueError: no such test method in <class 'mytestcase.MyTestCase'>: runTe ...

  3. <学习笔记: Django之初见>

    Django 1. web框架介绍 具体介绍Django之前,必须先介绍WEB框架等概念. web框架: 别人已经设定好的一个web网站模板,你学习它的规则,然后“填空”或“修改”成你自己需要的样子. ...

  4. Taurus.MVC 2.3.2 :WebAPI 文档集成测试功能及附加<%# JS执行功能语法 %>

    前言: 前些天有网友提到了那个界面丑陋的SwaggerUI,让我想起了多年前实现的WebAPI文档未完成的功能点,于是,动手了,便有了本文的内容. 开源地址:https://github.com/cy ...

  5. linux解压缩tar.gz文件

    1.解压缩命令 命令:tar -zxvf 文件名 -z 有gzip属性的 -x 解压 -v 显示所有过程 -f 要处理的文件名 2.压缩命令 命令: tar -zcxf 压缩后的文件名 要压缩的文件名 ...

  6. spring学习笔记(一)@ConfigurationProperties注解

    结论: 这个注解主要是为了将配置文件中的属性映射到实体类上,并且支持嵌套映射. 代码说明: @ConfigurationProperties(prefix = "person") ...

  7. LeetCode 102. 二叉树的层序遍历 | Python

    102. 二叉树的层序遍历 题目来源:https://leetcode-cn.com/problems/binary-tree-level-order-traversal 题目 给你一个二叉树,请你返 ...

  8. 目前校园百晓生APP与CSDN软件的对比

    不忘初心.注入灵魂 设计之初 在做校园百晓生该APP时,初心是为校园的同学提供便捷的查询校园信息的服务,确实目前的软件已经实现了该功能,但是总感觉缺少一些灵魂,感觉大部分人渴望的重点在于信息而不是自己 ...

  9. JDBC08时间处理

    时间类型 java.util.Date 子类: -java.sql.Date无时分秒 -java.sql.Time -java.sql.Timestamp

  10. pthon-安装新版PyQt5、PyQT5-tool后打不开并Designer.exe提示“This application failed to start because no Qt platform plugin could be initialized.Reinstalling the application the application may fix this program”

    最近学习python,安装网上教程一步一步的安装,网上很多帖子都写的非常详细,不由深深感慨多谢各位不辞辛苦的记录,指导着来自新入门的同学. 但是实际安装中,最理想莫过于一次性安装成功,但自己安装就出现 ...