2019-03-22
阅读量:
331
python如何计算所需时间
ctime(sec): - 此函数返回一个24个字符的时间字符串,但需要几秒作为参数,并计算直到所述秒数的时间。如果没有传递参数,则计算时间直到现在。
# Python code to demonstrate the working of
# asctime() and ctime()
# importing "time" module for time operations
import time
# initializing time using gmtime()
ti = time.gmtime()
# using asctime() to display time acc. to time mentioned
print ("Time calculated using asctime() is : ",end="")
print (time.asctime(ti))
# using ctime() to diplay time string using seconds
print ("Time calculated using ctime() is : ", end="")
print (time.ctime())
输出:
Time calculated using asctime() is : Tue Aug 2 07:47:02 2016
Time calculated using ctime() is : Tue Aug 2 07:47:02 2016






评论(0)


暂无数据
推荐帖子
0条评论
0条评论
0条评论