少说话多写代码之Python学习061——标准模块(time模块)

栏目: Python · 发布时间: 7年前

内容简介:日期模块主要是处理日期的,可以实现获取当前时间、操作时间和日期、将字符串格式化为日期以及将日期格式化为字符串。主要函数有,asctime 将时间元组转换为字符

日期模块主要是处理日期的,可以实现获取当前时间、操作时间和日期、将字符串格式化为日期以及将日期格式化为字符串。

主要函数有,

asctime 将时间元组转换为字符

localtime 将秒数转换为日期元组,

mktime 将时间元组转换为本地时间

sleep 休眠

strptime 将字符串解析为时间元组

time 当前时间

import time
now = time.asctime()
print(now)
print(time.localtime())
输出
Sat Dec 15 23:27:13 2018
time.struct_time(tm_year=2018, tm_mon=12, tm_mday=15, tm_hour=23, tm_min=27, tm_sec=13, tm_wday=5, tm_yday=349, tm_isdst=0)

具体函数在使用时查找对应文档即可。

工程文件下载: https://download.csdn.net/download/yysyangyangyangshan/10853235


以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Large-Scale Inference

Large-Scale Inference

Bradley Efron / Cambridge University Press / 2010-8-5 / GBP 48.00

We live in a new age for statistical inference, where modern scientific technology such as microarrays and fMRI machines routinely produce thousands and sometimes millions of parallel data sets, each ......一起来看看 《Large-Scale Inference》 这本书的介绍吧!

CSS 压缩/解压工具
CSS 压缩/解压工具

在线压缩/解压 CSS 代码

RGB CMYK 转换工具
RGB CMYK 转换工具

RGB CMYK 互转工具