• time模块


     1 import time
     2 
     3 # print(help(time.strftime))
     4 """
     5 %Y  Year with century as a decimal number.
     6 %m  Month as a decimal number [01,12].
     7 %d  Day of the month as a decimal number [01,31].
     8 %H  Hour (24-hour clock) as a decimal number [00,23].
     9 %M  Minute as a decimal number [00,59].
    10 %S  Second as a decimal number [00,61].
    11 %z  Time zone offset from UTC.  +0800
    12 %a  Locale's abbreviated weekday name.  wed
    13 %A  Locale's full weekday name. Wednesday
    14 %b  Locale's abbreviated month name.
    15 %B  Locale's full month name.
    16 %c  Locale's appropriate date and time representation.
    17 %I  Hour (12-hour clock) as a decimal number [01,12].
    18 %p  Locale's equivalent of either AM or PM.
    19 %X  本地时间  16:50:32
    20 x    本地日期  04/26/17
    21 """
    22 
    23 print(time.time()) #时间戳 1493198419.0
    24 
    25 print("结构对象 --->字符串")
    26 print(time.strftime('%Y-%m-%d %X %z %p  %A',time.localtime())) #2017-04-26 16:50:32 +0800 PM  Wednesday
    27 print(time.strftime('%Y-%m-%d %x %z %p  %A',time.localtime())) #2017-04-26 04/26/17 +0800 PM  Wednesday
    28 print(time.strftime('%Y-%m-%d %H:%M:%S  %A',time.localtime())) #2017-04-26 16:55:23  Wednesday  ==%X
    29 
    30 print("字符串--->结构对象")
    31 print(time.strptime('2017-04-26','%Y-%m-%d'))
    32 print(time.strptime("Wed Apr 26 17:20:19 2017","%a %b %d %H:%M:%S %Y"))
    33 """
    34 time.struct_time(tm_year=2017, tm_mon=4, tm_mday=26, tm_hour=17,
    35 tm_min=20, tm_sec=19, tm_wday=2, tm_yday=116, tm_isdst=-1)
    36 
    37 time.struct_time(tm_year=2017, tm_mon=4, tm_mday=26, tm_hour=0,
    38 tm_min=0, tm_sec=0, tm_wday=2, tm_yday=116, tm_isdst=-1)
    39 """
    40 print("时间戳 --->结构对象")
    41 print(time.gmtime(time.time()+3600*24*3))  #三天
    42 print(time.localtime(time.time()))
    43 """
    44 time.struct_time(
    45  tm_year=2017, tm_mon=4, tm_mday=29, tm_hour=9, tm_min=15,
    46  tm_sec=24, tm_wday=5, tm_yday=119, tm_isdst=0)
    47 """
    48 """
    49 time.struct_time(
    50     tm_year=2017, tm_mon=4, tm_mday=26, tm_hour=0, tm_min=0, tm_sec=0,
    51     tm_wday=2, tm_yday=116, tm_isdst=-1)
    52 """
    53 print('--------结构对象》》》时间戳----------------------')
    54 print(time.mktime(time.localtime(time.time()+3600*24))) #1493198419.0
    55 print((1493284857.0-1493198419.0)/3600)  #24.010555555555555==1天
    56 
    57 print("时间戳与字符串时间没有直接转")
    58 print(time.ctime(1493198419.0))  #Wed Apr 26 17:20:19 2017


     

  • 相关阅读:
    python读取csv文件、excel文件并封装成dict类型的list,直接看代码
    利用Python获取cookie的方法,相比java代码简便不少
    关于appium操作真机打开app之后无法定位页面元素的问题的解决办法
    关于做移动端ui自动化测试使用PC代理网络会出现的问题
    接口测试面试问题总结-转载
    接口测试3-参数关联接口(从上一个接口中获取数据,访问幼儿园服务器接口无session)
    接口测试2-接口测试 get post请求
    HTTP协议
    接口测试1-概论
    python视频学习笔记8(函数返回值和参数进阶)
  • 原文地址:https://www.cnblogs.com/hongyongshang/p/6772053.html
Copyright © 2020-2023  润新知