Python 获取秒级时间戳与毫秒级时间戳
原文:Python获取秒级时间戳与毫秒级时间戳
1、获取秒级时间戳与毫秒级时间戳

import time
import datetime t = time.time() print (t) #原始时间数据
print (int(t)) #秒级时间戳
print (int(round(t * 1000))) #毫秒级时间戳 nowTime = lambda:int(round(t * 1000))
print (nowTime()); #毫秒级时间戳,基于lambda print (datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')) #日期格式化

返回
1499825149.26
1499825149
1499825149257
1499825149257
2017-07-12 10:05:49
2、将日期转为秒级时间戳
dt = '2018-01-01 10:40:30'
ts = int(time.mktime(time.strptime(dt, "%Y-%m-%d %H:%M:%S")))
print (ts)
返回
1514774430
3、将秒级时间戳转为日期
ts = 1515774430
dt = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(ts))
print(dt)
返回
2018-01-13 00:27:10
Python 获取秒级时间戳与毫秒级时间戳的更多相关文章
- Python获取秒级时间戳与毫秒级时间戳
获取秒级时间戳与毫秒级时间戳 import time import datetime t = time.time() print (t) #原始时间数据 print (int(t)) #秒级时间戳 p ...
- 获取秒级时间戳和毫秒级时间戳---基于python
获取秒级时间戳和毫秒级时间戳 import timeimport datetime t = time.time() print (t) #原始时间数据print (int(t)) #秒级时间戳prin ...
- 【C++】秒级时间戳,毫秒级时间戳
时间戳,秒级 测试代码: #include <iostream> #include <time.h> #include <windows.h> using name ...
- python 获取秒级时间间隔
import datetime,time start_tm=datetime.datetime.now() time.sleep() end_tm=datetime.datetime.now() pr ...
- mysql搭建亿级cmd5数据库,毫秒级查询 完全过程
前言: 最近也在玩数据库,感觉普通机子搞数据库,还是差了点,全文查找,慢的要查一分钟更久. 但是搞cmd5库很不错,亿级数据库,毫秒级. qq 944520563好吧,下面开始,首先你得需要一个mys ...
- python 获得毫秒级时间戳
import time import datetime t = time.time() print (t) #原始时间数据 print (int(t)) #秒级时间戳 print (int(round ...
- 【PHP】 毫秒级时间戳和日期格式转换
在并发量搞得情况下.需要开启毫秒级运算 mysql 支持: `create_time` datetime() DEFAULT NULL COMMENT '创建时间', 效果 PHP 代码实现: &l ...
- C++获取毫秒级时间戳
#include<chrono> auto timeNow = chrono::duration_cast<chrono::milliseconds>(chrono::sy ...
- python毫秒级sleep
Python中的sleep函数可以传小数进去,然后就可以进行毫秒级的延时了 # 例1:循环输出休眠1秒 import time i = 1 while i = 3: print i # 输出i i + ...
随机推荐
- 分析maven的优点
1.依赖管理: 就是对jar包的管理. 2.项目的一键构建: 编译--->测试--->运行--->打包--->安装 运行一个maven工程(web工程)只需要一个命令:toma ...
- 【原创】Silverlight的ComboBox.SelectValue无法赋值
前几天开发中 给ComboBox的SelectValue属性赋值是,老是赋不上去.之前SelectValue为Null,执行完调试看下,还是Null.很诡异 ComboBox的SelectVa ...
- linux下xampp(apache)中配置域名访问,以及遇到的问题
xampp中apache使用域名访问 一.首先找到/opt/lampp/etc/httpd.conf: # Virtual hosts Include etc/extra/httpd-vhosts.c ...
- iOS.AddFont
为iOS App 添加定制字体 http://www.developers-life.com/how-to-include-ttf-fonts-to-ios-app.html http://blog. ...
- 白盒静态自动化测试工具:FindBugs使用指南
目 录 1 FINDBUGS介绍 2 在ECLIPSE中安装FINDBUGS插件 3 在ECLIPSE中使用FINDBUGS操作步骤 3.1 ...
- c++ 对象复制引用时何时调用构造函数、析构函数
class TEST{ private : public : TEST() {std::cout << "constructor" << std::endl ...
- abp 的坑
多数据库连接问题 viewmodel的验证问题 发布后,一段查找sln查找代码无法适用生产环境问题 多语言问题,默认中文设置与模板配置文件不统一
- JSONModel简便应用
JSONModel, Mantle 这两个开源库都是用来进行封装JSON->Model的, 想想看, 直接向服务器发起一个请求,然后回来后,就是一个Model, 直接使用, 这是一个多么美好的事 ...
- 521. Longest Uncommon Subsequence I
static int wing=[]() { std::ios::sync_with_stdio(false); cin.tie(NULL); ; }(); class Solution { publ ...
- android apk签名原理
//这个md5跟腾讯的对应 public Signature getPackageSignature( ){ Context context=getContext(); String packageN ...