Python+Selenium进阶版(六)- Python获取系统时间和格式化时间显示
在实际项目的开发,获取项目根路径的相对路径写法是很有必要的,不要总是绝对路径。
目标:如何去获取和打印格式化系统时间。
具体代码:
# conding=utf-8
import time
class GetTime(object):
def get_system_time(self):
print(time.time())
# time.time()获取的是从1970年到现在的间隔,单位是秒
print(time.localtime())
new_time1 = time.strftime('%Y-%m-%d %H:%M:%S',time.localtime())
# 格式化时间,按照 2017-04-15 13:46:32的格式打印出来
print(new_time1)
new_time2 = time.strftime('%Y%m%d%H%M%S', time.localtime())
print(new_time2)
gettime = GetTime()
gettime.get_system_time()
运行结果:

参考文章:https://blog.csdn.net/u011541946/article/details/70184079

浙公网安备 33010602011771号