# -*- 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. vSphere可用性之三准备实验环境

    第三章 准备实验环境 在上篇内容中,讲述了进行VMware HA实验所必需的软硬件条件.接下来将使用这些来搭建实验环境.主要内容为依据拓扑图安装ESX主机系统.ISCSI存储系统. 此次实验环境的建置 ...

  2. CodeForces - 1245 C - Constanze's Machine

    Codeforces Round #597 (Div. 2) Constanze is the smartest girl in her village but she has bad eyesigh ...

  3. RF(控制台及日志输出中文乱码)

    1.查看 ride 版本,我这里是 RIDE 1.7.4.1 running on Python 3.6.0. 2.修改文件 D:\python3.6\Lib\site-packages\roboti ...

  4. Jenkins 项目构建

    一:新建项目 (1)点击新建,输入项目名称--构建一个自由风格的软件项目,点击ok (2)构建触发器-----设置每两分钟执行一次 其中有5个参数 (*****) 第一个是代表分钟  一小时内的分钟数 ...

  5. 如何使用简单 PHP 对象 POPO (Plain old PHP Object) 来优化你的代码

    如果您熟悉 Java,可能您已经知道 POJO (普通 Java 类). 因为 POJO 这个词最早是由 Martin Fowler.Rebecca Parsons 和 Josh MacKenzie ...

  6. vue-cli3使用全局scss

    在开发项目的时候,经常会出现多个元素样式相同,比如颜色相同.这里就需要我们设置公共样式,方便后期调试 一配置方法 1.在src/assets/styles目录下创建文件variable.scss // ...

  7. uniapp滚动监听元素

    鸽了这么久,一晃2个月过去了.自考+上班没时间记录. 前不久看到移动官网上的时间轴效果,看起来不错,我也来试着做一下. 需要元素滚动到视野内加载动画. 插件地址 https://ext.dcloud. ...

  8. SAP ME01创建货源清单

    1业务说明 此文档使用函数:ME_DIRECT_INPUT_SOURCE_LIST创建货源清单 2前台实现 事务代码:ME01 输入抬头信息 保存即可 3代码实现 3.1调用函数 定义参数 字段 调用 ...

  9. Oracle JDK究竟从哪个版本开始商用收费?

    经常被问到Oracle JDK是不是要钱了?收费了?从哪个版本开始商用收费? 木有错,Oracle JDK从2019年4月16号开始商用商用商用收费了!有图有真像: 2019年4月16日当天,Orac ...

  10. springboot启动报错:Handler dispatch failed; nested exception is java.lang.AbstractMethodError

    最近在用springboot构建项目,控制台报错:Handler dispatch failed; nested exception is java.lang.AbstractMethodError, ...