﻿{"id":517,"date":"2020-09-02T03:38:19","date_gmt":"2020-09-01T19:38:19","guid":{"rendered":"https:\/\/byy3.com\/?p=517"},"modified":"2021-01-09T10:10:09","modified_gmt":"2021-01-09T02:10:09","slug":"python3-8-%e5%bc%82%e5%b8%b8attributeerror-module-time-has-no-attribute-clock","status":"publish","type":"post","link":"https:\/\/byy3.com\/?p=517","title":{"rendered":"Python3.8 \u5f02\u5e38AttributeError module &#8216;time&#8217; has no attribute &#8216;clock&#8217;"},"content":{"rendered":"<h1>\u539f\u7531\uff1atime.clock() \u81ea\u4ecepython3.3\u4e4b\u540e\u5c31\u88ab\u5e9f\u9664<\/h1>\n<h1>\u51fa\u73b0\u5f02\u5e38\uff1a<\/h1>\n<p>\u5728pycharm\u4e2d\u52a0Python3.8\u73af\u5883\uff0c\u8c03\u7528time.clock\u51fa\u5f02\u5e38\uff1aAttributeError module 'time' has no attribute 'clock'<\/p>\n<h1><a name=\"t1\"><\/a><a name=\"t1\"><\/a>\u7ecf\u8fc7\u5ea6\u5a18\uff0c\u5176\u539f\u56e0\uff1a<\/h1>\n<p>Python3.8\u4e0d\u518d\u652f\u6301time.clock\uff0c\u4f46\u5728\u8c03\u7528\u65f6\u4f9d\u7136\u5305\u542b\u8be5\u65b9\u6cd5\uff1b<\/p>\n<h1><a name=\"t2\"><\/a><a name=\"t2\"><\/a>\u6709\u6548\u5904\u7406\uff1a<\/h1>\n<p>\u7528time.perf_counter()\u66ff\u6362<\/p>\n<pre><code class=\"hljs lua\"><\/code><\/pre>\n<ol class=\"hljs-ln\">\n<li>\n<div class=\"hljs-ln-numbers\">\n<div class=\"hljs-ln-line hljs-ln-n\" data-line-number=\"1\"><\/div>\n<\/div>\n<div class=\"hljs-ln-code\">\n<div class=\"hljs-ln-line\">import <span class=\"hljs-built_in\">time<\/span><\/div>\n<\/div>\n<\/li>\n<li>\n<div class=\"hljs-ln-numbers\">\n<div class=\"hljs-ln-line hljs-ln-n\" data-line-number=\"2\"><\/div>\n<\/div>\n<div class=\"hljs-ln-code\">\n<div class=\"hljs-ln-line\">tis1 =<span class=\"hljs-built_in\">time<\/span>.perf_counter()<\/div>\n<\/div>\n<\/li>\n<li>\n<div class=\"hljs-ln-numbers\">\n<div class=\"hljs-ln-line hljs-ln-n\" data-line-number=\"3\"><\/div>\n<\/div>\n<div class=\"hljs-ln-code\">\n<div class=\"hljs-ln-line\"><span class=\"hljs-built_in\">print<\/span>(<span class=\"hljs-string\">\"\u7b49\u5f855\u79d2......\"<\/span>)<\/div>\n<\/div>\n<\/li>\n<li>\n<div class=\"hljs-ln-numbers\">\n<div class=\"hljs-ln-line hljs-ln-n\" data-line-number=\"4\"><\/div>\n<\/div>\n<div class=\"hljs-ln-code\">\n<div class=\"hljs-ln-line\"><span class=\"hljs-built_in\">time<\/span>.sleep(<span class=\"hljs-number\">5<\/span>)<\/div>\n<\/div>\n<\/li>\n<li>\n<div class=\"hljs-ln-numbers\">\n<div class=\"hljs-ln-line hljs-ln-n\" data-line-number=\"5\"><\/div>\n<\/div>\n<div class=\"hljs-ln-code\">\n<div class=\"hljs-ln-line\">tis2=<span class=\"hljs-built_in\">time<\/span>.perf_counter()<\/div>\n<\/div>\n<\/li>\n<li>\n<div class=\"hljs-ln-numbers\">\n<div class=\"hljs-ln-line hljs-ln-n\" data-line-number=\"6\"><\/div>\n<\/div>\n<div class=\"hljs-ln-code\">\n<div class=\"hljs-ln-line\"><span class=\"hljs-built_in\">print<\/span>(tis2-tis1)<\/div>\n<\/div>\n<\/li>\n<\/ol>\n<pre><code class=\"hljs lua\"><\/code><\/pre>\n<pre><code class=\"hljs yaml\"><\/code><\/pre>\n<ol class=\"hljs-ln\">\n<li>\n<div class=\"hljs-ln-numbers\">\n<div class=\"hljs-ln-line hljs-ln-n\" data-line-number=\"1\"><\/div>\n<\/div>\n<div class=\"hljs-ln-code\">\n<div class=\"hljs-ln-line\"><span class=\"hljs-string\">\u7b49\u5f855\u79d2......<\/span><\/div>\n<\/div>\n<\/li>\n<li>\n<div class=\"hljs-ln-numbers\"><\/div>\n<\/li>\n<\/ol>\n<pre><code class=\"hljs yaml\"><\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u539f\u7531\uff1atime.clock() \u81ea\u4ecepython3.3\u4e4b\u540e\u5c31\u88ab\u5e9f\u9664 \u51fa\u73b0\u5f02\u5e38\uff1a \u5728pycharm\u4e2d\u52a0Pytho [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[20],"tags":[352],"class_list":["post-517","post","type-post","status-publish","format-standard","hentry","category-python","tag-python"],"_links":{"self":[{"href":"https:\/\/byy3.com\/index.php?rest_route=\/wp\/v2\/posts\/517","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/byy3.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/byy3.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/byy3.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/byy3.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=517"}],"version-history":[{"count":0,"href":"https:\/\/byy3.com\/index.php?rest_route=\/wp\/v2\/posts\/517\/revisions"}],"wp:attachment":[{"href":"https:\/\/byy3.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=517"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/byy3.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=517"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/byy3.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=517"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}