Home  >  Article  >  Backend Development  >  Python中的ctime()方法使用教程

Python中的ctime()方法使用教程

WBOY
WBOYOriginal
2016-06-06 11:17:141913browse

 ctime()方法转换,因为历元到表示本地时间的字符串表示以秒为单位的时间。如果不设置秒时或None,所返回的时间的当前time()被使用。使用asctime(localtime(secs))。不使用ctime()的区域信息。
语法

以下是ctime()方法的语法:

time.ctime([ sec ])

参数

  •     sec -- 这些都是秒数要被转换成字符串表示。

返回值

此方法不返回任何值。
例子

下面的例子显示了ctime()方法的使用。

#!/usr/bin/python
import time

print "time.ctime() : %s" % time.ctime()

当我们运行上面的程序,它会产生以下结果:

time.ctime() : Tue Feb 17 10:00:18 2014

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn