您现在的位置是:首页 > 创业项目创业项目

python内置的时间是多少?python0B12是多少?

baojie2022-04-30 19:14:19

简介  今天闲来无事,把手里积累了这么久的Python笔记资料整理了一下,发现其实有了这些,python入门真的不难,每天花点时间学,真的不会影响工作。学会一项就业技能和副业技能非常有益

  今天闲来无事,把手里积累了这么久的Python笔记资料整理了一下,发现其实有了这些,python入门真的不难,每天花点时间学,真的不会影响工作。学会一项就业技能和副业技能非常有益的!

  如果你也想学习Python提升自己,那么加我微信3386 7294 38,免费领取一份Python学习资料教程,有不懂得都可以问我。

python内置的时间是多少?python0B12是多少?

  无主要参数函数

  先解释一下时间戳,所说时间戳,即自1970年1月1日00:00:00所历经的分秒,随后就可以了解下边的函数了。下面编码默认设置

  fromtimeimport*

  implementation monotonic adjustable resolution

  'time' GetSystemTimeAsFileTime() False True 0.015625

  'thread_time' GetThreadTimes() True False 1e-07

  'process_time' GetProcessTimes() True False 1e-07

  'monotonic' GetTickCount64() True False 0.015625

  'perf_counter' QueryPerformanceCounter() True False 1e-07

  上边五组函数中,仅有time.time()的值具备一定的实际意义,别的值都只具备相对性的实际意义。

  根据get_clock_info函数可以查询这种时钟的特性,其I/O各自为

  implementation monotonic adjustable resolution

  'time' GetSystemTimeAsFileTime() False True 0.015625

  'thread_time' GetThreadTimes() True False 1e-07

  'process_time' GetProcessTimes() True False 1e-07

  'monotonic' GetTickCount64() True False 0.015625

  'perf_counter' QueryPerformanceCounter() True False 1e-07

  在其中,

  假如时钟可以全自动变更或由网站管理员手动式变更,则adjustable为True,不然为False。

  implementation表示用以获得时钟值的基本C函数的名字。

  假如时钟不可以后退,则monotonic为True,不然为False。

  resolution表示以秒为公司的时钟屏幕分辨率。

  下面可以测试一下这种时钟的特性。

  >>>deftest(n):

  ...aTime=time.time()

  ...aTh=time.thread_time()

  ...aPr=time.process_time()

  ...aMo=time.monotonic()

  ...aPe=time.perf_counter()

  ...foriinrange(int(n)):j=i**2

  ...bTime=time.time()

  ...bTh=time.thread_time()

  ...bPr=time.process_time()

  ...bMo=time.monotonic()

  ...bPe=time.perf_counter()

  ...aStr=f'aTime={aTime},aTh={aTh},aPr={aPr},aMo={aMo},aPe={aPe}

  '

  ...bStr=f'bTime={bTime},bTh={bTh},bPr={bPr},bMo={bMo},bPe={bPe}'

  ...print(aStr+bStr)

  ...

  >>>test(1e6)

  aTime=1634625786.136904,aTh=0.03125,aPr=0.03125,aMo=199082.078,aPe=199085.4751224

  bTime=1634625786.340363,bTh=0.234375,bPr=0.234375,bMo=199082.281,bPe=199085.6787309

  >>>test(1e6)

  aTime=1634625789.7817287,aTh=0.234375,aPr=0.234375,aMo=199085.734,aPe=199089.1195357

  bTime=1634625789.981198,bTh=0.421875,bPr=0.421875,bMo=199085.921,bPe=199089.3195721

  >>>test(1e6)

  aTime=1634625796.3934195,aTh=0.421875,aPr=0.421875,aMo=199092.343,aPe=199095.731209

  bTime=1634625796.5789576,bTh=0.609375,bPr=0.609375,bMo=199092.531,bPe=199095.9172852

  >>>

  可清楚地见到,在启用test的间距中,thread_time和process_time并没有产生变化,即二者不测算进程或是过程休眠状态时的時间。

  一般在time控制模块中,最经常使用的2个函数分别是time.time()和time.sleep(),前面一种用以获得时间戳,进而统计分析程序执行时间;后面一种则可以中止进程。

  可以根据time.thread_time()来检验sleep函数的作用

  >>>deftest(n):

  ...aTime=time.time()

  ...aTh=time.thread_time()

  ...aPr=time.process_time()

  ...time.sleep(n)

  ...bTime=time.time()

  ...bTh=time.thread_time()

  ...bPr=time.process_time()

  ...aStr=f'aTime={aTime},aTh={aTh},aPr={aPr}

  '

  ...bStr=f'bTime={bTime},bTh={bTh},bPr={bPr}'

  ...print(aStr+bStr)

  ...

  >>>test(1)

  aTime=1634649370.2819958,aTh=0.640625,aPr=0.640625

  bTime=1634649371.2862759,bTh=0.640625,bPr=0.640625

  >>>test(1)

  aTime=1634649372.72013,aTh=0.640625,aPr=0.640625

  bTime=1634649373.723695,bTh=0.640625,bPr=0.640625

  >>>test(1)

  时区时间定义

  下面必须详细介绍一些相关时间的概念

  GMT:即格林威治国际标准时间。

  Python民宿客栈发红包、实体书

  UTC:全球融洽時间,比格林威治更

关于我们

现在最火的自媒体,就是抖音运营。而关于抖音 运营网上的很多文章都是过时的,落伍的。我联合互联上的大牛组织了抖音运营大佬的学习社群,这里有免费的学习资源,每天直播分享自媒体教学与抖音运营和网络营销的引流最新技术,需要的可以联系我的微信:aibo474,不是学习的就不要加了。

添加学习