最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
python中time.ctime()实例用法代码
时间:2021-02-03 编辑:袖梨 来源:一聚教程网
本篇文章小编给大家分享一下python中time.ctime()实例用法代码,文章代码介绍的很详细,小编觉得挺不错的,现在分享给大家供大家参考,有需要的小伙伴们可以来看看。
1.说明
该函数把时间秒数转为字符串。
2.语法
time.ctime([ sec ])
3.参数
sec -- 要转换为字符串时间的秒数。
4.返回值
该函数没有任何返回值。
5.实例
//连续每隔1秒加印系统的当前时间 //使用sleep来进行不精确的延时 #include#include int main(void) { time_t timetemp; //定义一个时间结构体变量 while(1) { time(&timetemp); //获取时间参数 printf("%s", ctime(&timetemp)); //打印当前时间 sleep(1); } return 0; }
实例扩展:
以下实例展示了 ctime() 函数的使用方法:
#!/usr/bin/python import time print "time.ctime() : %s" % time.ctime()
以上实例输出结果为:
time.ctime() : Tue Feb 17 10:00:18 2013
相关文章
- Golang ProtoBuf的基本语法详解 10-20
- Python识别MySQL中的冗余索引解析 10-20
- Python+Pygame绘制小球代码展示 10-18
- Python中的数据精度问题介绍 10-18
- Python随机值生成的常用方法介绍 10-18
- python3解压缩.gz文件分析 09-27