在实际项目的开发,获取项目根路径的相对路径写法是很有必要的,不要总是绝对路径。

  目标:如何去获取和打印格式化系统时间。

  具体代码:

# 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()

 

  运行结果:

Python+Selenium进阶版(六)- Python获取系统时间和格式化时间显示

 

 

  

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

  

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-20
  • 2022-12-23
  • 2021-11-18
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-01-15
  • 2021-11-28
  • 2022-12-23
  • 2022-12-23
  • 2021-10-17
  • 2022-12-23
  • 2021-09-22
相关资源
相似解决方案