热线电话:13121318867

登录
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
7.7906
3
关注作者
收藏
评论(0)

发表评论

暂无数据
推荐帖子