美文网首页
python时间

python时间

作者: MagicalGuy | 来源:发表于2018-10-09 00:17 被阅读0次

encoding:utf-8

import time

获取当地前时间, 并并转换成格式化字符串

1. 获取当前的时间戳

curTime = time.time()
print(curTime)

2. 将时间戳转换成可读的格式

timeTuple = time.localtime(curTime)
print(timeTuple)

3. 转换成格式化字符串

strTime = time.strftime('%m/%d/%Y %H:%M:%S',timeTuple)
print(strTime)

参数的单位是秒

time.sleep(0.5)

相关文章

  • python对时间序列的处理

    简单介绍python处理时间。 基础python处理时间与日期 python基本的处理时间对象是datetime模...

  • python时间

    encoding:utf-8 import time 获取当地前时间, 并并转换成格式化字符串 1. 获取当前的时...

  • Python——时间

    time函数 time()获取当前的时间戳,localtime()格式化当前的时间戳,转换成time.struct...

  • Python时间

    timeimport timetime.time() #获取时间戳,单位:秒time.clock() ...

  • learning

    python在终端进行文件的运行在终端输入 python test.py 时间时间的转换 编码python编码问题

  • 2019-06-20

    python 生成当前时间时间戳 获取指定年月日时间戳 python 连接数据库

  • python的学习方向

    我的学习计划: 1、Python基础语法、python字符串解析、python时间和日历、python文件操作,数...

  • Python-- 时间和日期

    Python 时间+日期

  • Python time.time()方法

    Python time.time()方法 描述 Python time.time()返回当前时间的时间戳(1970...

  • 2019-02-17

    Python time strftime()方法 描述Python time strftime() 函数接收以时间...

网友评论

      本文标题:python时间

      本文链接:https://www.haomeiwen.com/subject/gvplaftx.html