python3练习100题——010

第10天了,今天的题目跟009类似,都比较水,有时间的话再做一道~

链接:http://www.runoob.com/python/python-exercise-example10.html

题目:暂停一秒输出,并格式化当前时间。

不会做,直接看答案:

import time
 
print (time.strftime('%Y-%m-%d %H:%M:%S'))
time.sleep(1)
print (time.strftime('%Y-%m-%d %H:%M:%S'))

思考:

Python time strftime() 函数接收以时间元组,并返回以可读字符串表示的当地时间,格式由参数format决定。

语法:time.strftime(format[, t])

猜你喜欢

转载自www.cnblogs.com/drifter/p/9103756.html