{"id":1635,"date":"2020-06-21T21:00:55","date_gmt":"2020-06-21T13:00:55","guid":{"rendered":"http:\/\/39.97.231.10\/?p=1635"},"modified":"2020-06-21T21:00:55","modified_gmt":"2020-06-21T13:00:55","slug":"python-%e7%9a%84-datetime-%e6%a8%a1%e5%9d%97","status":"publish","type":"post","link":"http:\/\/www.weijing.co\/?p=1635","title":{"rendered":"Python \u7684 datetime \u6a21\u5757"},"content":{"rendered":"<div>\nPython \u7684 datetime \u6a21\u5757\u53ef\u4ee5\u81ea\u5b9a\u4e49\u65e5\u671f\u7684\u663e\u793a\u683c\u5f0f\uff0c\u800c\u4e14\u8fd8\u53ef\u4ee5\u5f88\u65b9\u4fbf\u5730\u5bf9\u65e5\u671f\u8fdb\u884c\u7b97\u672f\u8fd0\u7b97\uff0c\u6bd4\u5982\u589e\u51cf\u5929\u6570\u7b49\u64cd\u4f5c\u3002<br \/>\ndatetime \u6a21\u5757\u5b9a\u4e49\u4e86 datetime \u6570\u636e\u7c7b\u578b\uff0c\u7528\u4e8e\u8868\u793a\u4e00\u4e2a\u7279\u5b9a\u7684\u65f6\u523b\u3002<\/p>\n<div>\n<pre>import datetime\nimport logging\nimport time\nlogging.basicConfig(level=logging.DEBUG, format=\\'%(levelname)s - %(message)s\\')\n\\'\\'\\'\ndatetime \u6a21\u5757\n@author Deniro Lee\n\\'\\'\\'\ndt = datetime.datetime(2020, 10, 21, 17, 32, 34)\nlogging.info(\\'%s-%s-%s %s:%s:%s\\', dt.year, dt.month, dt.day, dt.hour, dt.minute, dt.second)\n<\/pre>\n<\/div>\n<p>\u8fd0\u884c\u7ed3\u679c\uff1a<\/p>\n<div>\n<pre>INFO - 2020-10-21 17:32:34\n<\/pre>\n<\/div>\n<h2>1 \u8f6c\u6362 Unix \u7eaa\u5143\u65f6\u95f4\u6233<\/h2>\n<p>Unix \u7eaa\u5143\u65f6\u95f4\u6233\u53ef\u4ee5\u901a\u8fc7 datetime.datetime.fromtimestamp() \uff0c\u8f6c\u6362\u4e3a datetime \u5bf9\u8c61\u3002 datetime \u5bf9\u8c61\u7684\u65e5\u671f\u548c\u65f6\u95f4\u4f1a\u6839\u636e\u672c\u5730\u65f6\u533a\u81ea\u52a8\u8f6c\u6362\u3002<\/p>\n<div>\n<pre>dt = datetime.datetime.fromtimestamp(10000000)\nlogging.info(\\'from 10000000 -&gt; %s\\', dt)\ndt = datetime.datetime.fromtimestamp(time.time())\nlogging.info(\\'from now -&gt; %s\\', dt)\n<\/pre>\n<\/div>\n<p>\u8fd0\u884c\u7ed3\u679c\uff1a<\/p>\n<div>\n<pre>INFO - from 10000000 -&gt; 1970-04-27 01:46:40\nINFO - from now -&gt; 2020-01-19 10:23:14.695018\n<\/pre>\n<\/div>\n<h2>2 \u6bd4\u8f83\u65f6\u95f4<\/h2>\n<p>datetime \u5bf9\u8c61\u53ef\u4ee5\u7528\u6bd4\u8f83\u64cd\u4f5c\u7b26\u8fdb\u884c\u65f6\u95f4\u6bd4\u8f83\u3002<\/p>\n<div>\n<pre>new_year_2019 = datetime.datetime(2019, 1, 1, 0, 0, 0)\nnew_year_2020 = datetime.datetime(2020, 1, 1, 0, 0, 0)\nlogging.info(\\'2019 &gt; 2020 -&gt; %s\\', new_year_2019 &gt; new_year_2020)\nlogging.info(\\'2019 &lt; 2020 -&gt; %s\\', new_year_2019 &lt; new_year_2020)\nlogging.info(\\'2019 != 2020 -&gt; %s\\', new_year_2019 != new_year_2020)\n<\/pre>\n<\/div>\n<p>\u8fd0\u884c\u7ed3\u679c\uff1a<\/p>\n<div>\n<pre>INFO - 2019 &gt; 2020 -&gt; False\nINFO - 2019 &lt; 2020 -&gt; True\nINFO - 2019 != 2020 -&gt; True\n<\/pre>\n<\/div>\n<p>\u5229\u7528\u6bd4\u8f83\u65f6\u95f4\u65b9\u6cd5\uff0c\u6211\u4eec\u53ef\u4ee5\u5b9e\u73b0\u4e00\u4e2a\u8ba1\u5212\u4efb\u52a1\uff0c\u6bd4\u5982\u7a0b\u5e8f\u5230\u67d0\u4e00\u65f6\u523b\u65f6\uff0c\u624d\u5f00\u59cb\u6267\u884c\u4e1a\u52a1\u903b\u8f91\u3002<\/p>\n<div>\n<pre>dt = datetime.datetime(2020, 10, 21, 17, 32, 34)\nwhile datetime.datetime.now() &lt; dt:\n    time.sleep(1)\n    logging.info(\\'sleep ...\\')\n<\/pre>\n<\/div>\n<p>\u8fd0\u884c\u7ed3\u679c\uff1a<\/p>\n<div>\n<pre>INFO - sleep ...\nINFO - sleep ...\nINFO - sleep ...\n<\/pre>\n<\/div>\n<p>\u8fd9\u91cc\u5229\u7528\u4e86\u4e00\u4e2a while \u5faa\u73af\uff0c\u8ba9\u7a0b\u5e8f\u76f4\u5230\u67d0\u4e00\u4e2a\u7279\u5b9a\u7684\u65f6\u95f4\u5230\u6765\u4e4b\u524d\uff0c\u4e00\u76f4\u5904\u4e8e\u4f11\u7720\u72b6\u6001\u3002<\/p>\n<h2>3 timedelta \u6570\u636e\u7c7b\u578b<\/h2>\n<p>datetime \u6a21\u5757\u8fd8\u5b9a\u4e49\u4e86 timedelta \u6570\u636e\u7c7b\u578b\uff0c\u5b83\u8868\u793a\u7684\u662f\u4e00\u6bb5\u65f6\u95f4\u3002<\/p>\n<div>\n<pre>delta = datetime.timedelta(days=12, hours=8, minutes=36, seconds=58)\nlogging.info(\\'delta.days -&gt; %s,delta.seconds -&gt; %s,delta.microseconds -&gt; %s\\', delta.days, delta.seconds,\n             delta.microseconds)\nlogging.info(\\'total_seconds -&gt; %s\\', delta.total_seconds())\nlogging.info(\\'delta -&gt; %s\\', delta)\n<\/pre>\n<\/div>\n<p>\u8fd0\u884c\u7ed3\u679c\uff1a<\/p>\n<div>\n<pre>INFO - delta.days -&gt; 12,delta.seconds -&gt; 31018,delta.microseconds -&gt; 0\nINFO - total_seconds -&gt; 1067818.0\nINFO - delta -&gt; 12 days, 8:36:58\n<\/pre>\n<\/div>\n<p>\u4f7f\u7528 datetime.timedelta()\u51fd\u6570\u6765\u521b\u5efa timedelta \u5bf9\u8c61\uff0c\u5b83\u63a5\u53d7\u5173\u952e\u5b57\u53c2\u6570 weeks\u3001 days\u3001 hours\u3001 minutes\u3001 seconds\u3001 milliseconds \u548c microseconds\u3002\u6ce8\u610f\uff1a \u8fd9\u91cc\u6ca1\u6709 month \u548c year \u5173\u952e\u5b57\u53c2\u6570\uff0c\u56e0\u4e3a\u201c\u6708\u201d\u548c\u201c\u5e74\u201d\u53ef\u4ee5\u901a\u8fc7\u5176\u5b83\u5173\u952e\u5b57\u53c2\u6570\u63a8\u7b97\u51fa\u6765\u3002<br \/>\ntimedelta \u5bf9\u8c61\u62e5\u6709\u7684\u603b\u65f6\u95f4\u4ee5\u5929 \u3001 \u79d2 \u3001 \u5fae\u79d2\u6765\u8868\u793a\u3002\u8fd9\u4e9b\u503c\u5206\u522b\u4fdd\u5b58\u5728 days \u3001 seconds\u548c microseconds \u5c5e\u6027\u4e2d \u3002total_seconds() \u65b9\u6cd5\u4f1a\u8fd4\u56de\u4ee5\u79d2\u8868\u793a\u7684\u65f6\u957f\u3002\u628a\u4e00\u4e2a timedelta \u5bf9\u8c61\u4f20\u5165 str() \uff0c\u5c31\u4f1a\u8fd4\u56de\u683c\u5f0f\u826f\u597d\u7684 \u3001 \u53ef\u4f9b\u4eba\u9605\u8bfb\u7684\u5b57\u7b26\u4e32\u8868\u793a\u5f62\u5f0f\u3002<\/p>\n<h2>4 \u65f6\u95f4\u8fd0\u7b97<\/h2>\n<p>\u53ef\u4ee5\u4f7f\u7528\u7b97\u672f\u8fd0\u7b97\u7b26\u5bf9 datetime \u503c\u8fdb\u884c\u8fd0\u7b97\u3002<\/p>\n<div>\n<pre>dt = datetime.datetime(2020, 10, 21, 17, 32, 34)\nlogging.info(\\'current time -&gt; %s\\', dt)\ndays_30 = datetime.timedelta(days=30)\nlogging.info(\\'after 30 days -&gt; %s\\', dt + days_30)\n<\/pre>\n<\/div>\n<p>\u8fd0\u884c\u7ed3\u679c\uff1a<\/p>\n<div>\n<pre>INFO - delta.days -&gt; 12,delta.seconds -&gt; 31018,delta.microseconds -&gt; 0\nINFO - total_seconds -&gt; 1067818.0\nINFO - delta -&gt; 12 days, 8:36:58\n<\/pre>\n<\/div>\n<p>\u5229\u7528+\u548c-\u8fd0\u7b97\u7b26\uff0c\u6211\u4eec\u53ef\u4ee5\u628a timedelta \u5bf9\u8c61\u4e0e datetime \u5bf9\u8c61\u6216\u5176\u4ed6 timedelta \u5bf9\u8c61\u8fdb\u884c\u76f8\u52a0\u6216\u76f8\u51cf\u3002timedelta \u5bf9\u8c61\u8fd8\u652f\u6301\u4e58\u3001\u9664\u8fd0\u7b97\u3002<\/p>\n<div>\n<pre>dt = datetime.datetime(2020, 10, 21, 17, 32, 34)\ndays_150 = datetime.timedelta(days=30 * 5)\nlogging.info(\\'after 150 days -&gt; %s\\', days_150)\nlogging.info(\\'dt-days_150 -&gt; %s\\', dt - days_150)\nlogging.info(\\'dt-days_150 * 2 -&gt; %s\\', dt - days_150 * 2)\n<\/pre>\n<\/div>\n<p>\u8fd0\u884c\u7ed3\u679c\uff1a<\/p>\n<div>\n<pre>INFO - after 150 days -&gt; 150 days, 0:00:00\nINFO - dt-days_150 -&gt; 2020-05-24 17:32:34\nINFO - dt-days_150 * 2 -&gt; 2019-12-26 17:32:34\n<\/pre>\n<\/div>\n<h2>5 datetime \u5bf9\u8c61\u4e0e\u5b57\u7b26\u4e32\u4e4b\u95f4\u76f8\u4e92\u8f6c\u6362<\/h2>\n<p>\u5229\u7528 strftime() \u65b9\u6cd5\uff0c\u6211\u4eec\u53ef\u4ee5\u5c06 datetime \u5bf9\u8c61\u8f6c\u6362\u4e3a\u66f4\u53ef\u8bfb\u7684\u5b57\u7b26\u4e32\u3002 str ftime() \u51fd\u6570\u540d\u4e2d\u7684 f \u8868\u793a format\u3002<br \/>\nstrftime() \u65b9\u6cd5\u652f\u6301\u4ee5\u4e0b\u683c\u5f0f\u5316\u6307\u4ee4\uff1a<\/p>\n<table>\n<thead>\n<tr>\n<th>\u683c\u5f0f\u5316\u6307\u4ee4<\/th>\n<th>\u542b\u4e49<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>%Y<\/td>\n<td>\u5e26\u4e16\u7eaa\u7684\u5e74\u4efd\uff0c\u4f8b\u5982\\&#8217;2020\\&#8217;<\/td>\n<\/tr>\n<tr>\n<td>%y<\/td>\n<td>\u4e0d\u5e26\u4e16\u7eaa\u7684\u5e74\u4efd\uff0c \\&#8217;00\\&#8217;\u81f3\\&#8217;99\\&#8217;\uff081970 \u81f3 2069\uff09<\/td>\n<\/tr>\n<tr>\n<td>%m<\/td>\n<td>\u6570\u5b57\u8868\u793a\u7684\u6708\u4efd, \\&#8217;01\\&#8217;\u81f3\\&#8217;12\\&#8217;<\/td>\n<\/tr>\n<tr>\n<td>%B<\/td>\n<td>\u5b8c\u6574\u7684\u6708\u4efd\uff0c\u4f8b\u5982\\&#8217;November\\&#8217;<\/td>\n<\/tr>\n<tr>\n<td>%b<\/td>\n<td>\u7b80\u5199\u7684\u6708\u4efd\uff0c\u4f8b\u5982\\&#8217;Nov\\&#8217;<\/td>\n<\/tr>\n<tr>\n<td>%d<\/td>\n<td>\u4e00\u6708\u4e2d\u7684\u7b2c\u51e0\u5929\uff0c \\&#8217;01\\&#8217;\u81f3\\&#8217;31\\&#8217;<\/td>\n<\/tr>\n<tr>\n<td>%j<\/td>\n<td>\u4e00\u5e74\u4e2d\u7684\u7b2c\u51e0\u5929\uff0c \\&#8217;001\\&#8217;\u81f3\\&#8217;366\\&#8217;<\/td>\n<\/tr>\n<tr>\n<td>%w<\/td>\n<td>\u4e00\u5468\u4e2d\u7684\u7b2c\u51e0\u5929\uff0c \\&#8217;0\\&#8217;\uff08\u5468\u65e5\uff09\u81f3\\&#8217;6\\&#8217;\uff08\u5468\u516d\uff09<\/td>\n<\/tr>\n<tr>\n<td>%A<\/td>\n<td>\u5b8c\u6574\u7684\u5468\u51e0\uff0c\u4f8b\u5982\\&#8217;Monday\\&#8217;<\/td>\n<\/tr>\n<tr>\n<td>%a<\/td>\n<td>\u7b80\u5199\u7684\u5468\u51e0\uff0c\u4f8b\u5982\\&#8217;Mon\\&#8217;<\/td>\n<\/tr>\n<tr>\n<td>%H<\/td>\n<td>\u5c0f\u65f6\uff0824 \u5c0f\u65f6\u65f6\u949f\uff09\uff0c \\&#8217;00\\&#8217;\u81f3\\&#8217;23\\&#8217;<\/td>\n<\/tr>\n<tr>\n<td>%I<\/td>\n<td>\u5c0f\u65f6\uff0812 \u5c0f\u65f6\u65f6\u949f\uff09\uff0c \\&#8217;01\\&#8217;\u81f3\\&#8217;12\\&#8217;<\/td>\n<\/tr>\n<tr>\n<td>%M<\/td>\n<td>\u5206\uff0c \\&#8217;00\\&#8217;\u81f3\\&#8217;59\\&#8217;<\/td>\n<\/tr>\n<tr>\n<td>%S<\/td>\n<td>\u79d2\uff0c \\&#8217;00\\&#8217;\u81f3\\&#8217;59\\&#8217;<\/td>\n<\/tr>\n<tr>\n<td>%p<\/td>\n<td>\\&#8217;AM\\&#8217;\u6216\\&#8217;PM\\&#8217;<\/td>\n<\/tr>\n<tr>\n<td>%%<\/td>\n<td>\u8f6c\u4e49\u51fa\\&#8217;%\\&#8217;\u5b57\u7b26<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u5411 strftime() \u65b9\u6cd5\u4f20\u5165\u4e00\u4e2a\u81ea\u5b9a\u4e49\u7684\u683c\u5f0f\u5b57\u7b26\u4e32\uff0c\u5176\u4e2d\u5305\u542b\u683c\u5f0f\u5316\u6307\u4ee4\uff0c strftime() \u5c31\u4f1a\u8fd4\u56de\u76f8\u5e94\u683c\u5f0f\u7684\u5b57\u7b26\u4e32\u3002<br \/>\n\u5982\u679c\u8981\u5c06\u5b57\u7b26\u4e32\u8f6c\u6362\u6210 datetime \u5bf9\u8c61\uff0c\u5c31\u662f\u7528\u53cd\u5411\u64cd\u4f5c\u65b9\u6cd5 strptime()\uff0c\u5b83\u6240\u652f\u6301\u7684\u683c\u5f0f\u5316\u6307\u4ee4\u4e0e strftime() \u65b9\u6cd5\u76f8\u540c\u3002<\/p>\n<blockquote><p>\u6ce8\u610f\uff1a strptime() \u7684\u7b2c\u4e00\u4e2a\u5165\u53c2\u662f\u5e26\u6709\u65e5\u671f\u4fe1\u606f\u7684\u5b57\u7b26\u4e32\uff0c\u5b83\u5fc5\u987b\u51c6\u786e\u5339\u914d\u5b9a\u5236\u7684\u683c\u5f0f\u5b57\u7b26\u4e32\uff0c\u5426\u5219 Python \u4f1a\u629b\u51fa ValueError \u5f02\u5e38\u3002<\/p><\/blockquote>\n<div><button type=\\\"button\\\" aria-label=\\\"\u590d\u5236\u4ee3\u7801\\\"><\/button><\/p>\n<pre># datetime \u5bf9\u8c61\u8f6c\u6362\u4e3a\u5b57\u7b26\u4e32\ndt = datetime.datetime(2020, 10, 21, 17, 32, 34)\nlogging.info(\\'format -&gt; %s\\', dt.strftime(\\'%Y-%m-%d %H:%M:%S\\'))\nlogging.info(\\'format -&gt; %s\\', dt.strftime(\\'%I:%M %p\\'))\nlogging.info(\\'format -&gt; %s\\', dt.strftime(\\'%B of %y, %A\\'))\n# \u5b57\u7b26\u4e32\u8f6c\u6362\u4e3a datetime \u5bf9\u8c61\ndt = datetime.datetime.strptime(\\'2020-10-21 17:32:34\\', \\'%Y-%m-%d %H:%M:%S\\')\nlogging.info(\\'str to datetime -&gt; %s(%s)\\', dt, type(dt))\n<\/pre>\n<\/div>\n<p>\u8fd0\u884c\u7ed3\u679c\uff1a<\/p>\n<div>\n<pre>INFO - format -&gt; 2020-10-21 17:32:34\nINFO - format -&gt; 05:32 PM\nINFO - format -&gt; October of 20, Wednesday\nINFO - str to datetime -&gt; 2020-10-21 17:32:34(&lt;class \\'datetime.datetime\\'&gt;)\n<\/pre>\n<\/div>\n<hr \/>\n<p>\u603b\u7ed3\u5982\u4e0b\uff1a<br \/>\n\uff081\uff09\u8868\u793a\u65f6\u95f4\u7684 3 \u79cd\u4e0d\u540c\u7c7b\u578b\u5bf9\u8c61<\/p>\n<ul>\n<li>Unix \u7eaa\u5143\u65f6\u95f4\u6233\uff08time \u6a21\u5757\uff09\u662f\u4e00\u4e2a\u6d6e\u70b9\u503c\u6216\u6574\u578b\u503c\uff0c\u5b83\u8868\u793a\u81ea 1970 \u5e741\u67081\u65e5\u5348\u591c 0 \u70b9\uff08 UTC \uff09\u4ee5\u6765\u7684\u79d2\u6570\u3002<\/li>\n<li>datetime \u5bf9\u8c61\uff08datetime \u6a21\u5757\uff09\u5305\u542b\u4e00\u4e9b\u6574\u578b\u503c\uff0c\u4fdd\u5b58\u5728 year\u3001 month \u3001 day \u3001 hour \u3001 minute \u548c second \u7b49\u5c5e\u6027\u4e2d\u3002<\/li>\n<li>timedelta \u5bf9\u8c61\uff08datetime \u6a21\u5757\uff09\u8868\u793a\u7684\u662f\u4e00\u6bb5\u65f6\u95f4\uff0c\u800c\u4e0d\u662f\u4e00\u4e2a\u7279\u5b9a\u7684\u65f6\u523b\u3002<\/li>\n<\/ul>\n<p>\uff082\uff09\u65f6\u95f4\u51fd\u6570\u3001\u53c2\u6570\u53ca\u5176\u8fd4\u56de\u503c<\/p>\n<ul>\n<li>time.time() \u51fd\u6570\u8fd4\u56de\u4e00\u4e2a\u6d6e\u70b9\u503c\uff0c\u8868\u793a\u5f53\u524d\u65f6\u523b\u7684 Unix \u7eaa\u5143\u65f6\u95f4\u6233\u3002<\/li>\n<li>time.sleep(second s)\u51fd\u6570\u4f1a\u8ba9\u7a0b\u5e8f\u6682\u505c\u6307\u5b9a\u7684\u79d2\u6570 s\u3002<\/li>\n<li>datetime.datetime (year\uff0c month \uff0c day \uff0c hour \uff0c minute \uff0c second ) \u51fd\u6570\u8fd4\u56de\u53c2\u6570\u6307\u5b9a\u7684\u65f6\u523b\u7684 datetime \u5bf9\u8c61\u3002\u5982\u679c\u6ca1\u6709\u63d0\u4f9b hour \u3001 minute \u6216 second \u53c2\u6570\uff0c\u5219\u4f7f\u7528\u9ed8\u8ba4\u503c 0 \u3002<\/li>\n<li>datetime.datetime.now() \u51fd\u6570\u8fd4\u56de\u5f53\u524d\u65f6\u523b\u7684 datetime \u5bf9\u8c61\u3002<\/li>\n<li>datetime.datetime.fromtimestamp( epoch ) \u51fd\u6570\u8fd4\u56de epoch \u65f6\u95f4\u6233\u53c2\u6570\u8868\u793a\u7684\u65f6\u523b\uff0c\u5373Unix \u7eaa\u5143\u65f6\u95f4\u6233\u7684 datetime \u5bf9\u8c61\u3002<\/li>\n<li>datetime.timedelta(weeks\uff0c days\uff0c hours\uff0c minutes\uff0c seconds\uff0cmilliseconds\uff0cmicroseconds)\u51fd\u6570\u8fd4\u56de\u4e00\u4e2a\u8868\u793a\u4e00\u6bb5\u65f6\u95f4\u7684 timedelta\u5bf9\u8c61\u3002\u8be5\u51fd\u6570\u7684\u5173\u952e\u5b57\u53c2\u6570\u90fd\u662f\u53ef\u9009\u7684\uff0c\u4e0d\u5305\u62ec month \u6216year\u3002<\/li>\n<li>total_ seconds()\u65b9\u6cd5\u7528\u4e8e timedelta\u5bf9\u8c61\uff0c\u8fd4\u56de timedelta\u5bf9\u8c61\u8868\u793a\u7684\u79d2\u6570\u3002<\/li>\n<li>datetime.datetime.strftime ( format )\u65b9\u6cd5\u8fd4\u56de\u4e00\u4e2a\u5b57\u7b26\u4e32\uff0c\u7528 format \u5b57\u7b26\u4e32\u4e2d\u7684\u5b9a\u5236\u683c\u5f0f\u6765\u8868\u793adatetime \u5bf9\u8c61\u8868\u793a\u7684\u65f6\u95f4\u5b57\u7b26\u4e32\u3002<\/li>\n<li>datetime.datetime.strptime ( time_string\uff0c format )\u51fd\u6570\u8fd4\u56de\u4e00\u4e2adatetime \u5bf9\u8c61\uff0c\u5b83\u7684\u65f6\u523b\u7531 time_string\u6307\u5b9a\uff0c\u5229\u7528 format \u5b57\u7b26\u4e32\u53c2\u6570\u6765\u89e3\u6790\u3002<\/li>\n<\/ul>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Python \u7684 datetime \u6a21\u5757\u53ef\u4ee5\u81ea\u5b9a\u4e49\u65e5\u671f\u7684\u663e\u793a\u683c\u5f0f\uff0c\u800c\u4e14\u8fd8\u53ef\u4ee5\u5f88\u65b9\u4fbf\u5730\u5bf9\u65e5\u671f\u8fdb\u884c\u7b97\u672f\u8fd0\u7b97\uff0c\u6bd4\u5982\u589e &hellip;<\/p>\n<p class=\"read-more\"> <a class=\"\" href=\"http:\/\/www.weijing.co\/?p=1635\"> <span class=\"screen-reader-text\">Python \u7684 datetime \u6a21\u5757<\/span> \u67e5\u770b\u5168\u6587 &raquo;<\/a><\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"default","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"default","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":""},"categories":[106,126],"tags":[],"uagb_featured_image_src":{"full":false,"thumbnail":false,"medium":false,"medium_large":false,"large":false,"1536x1536":false,"2048x2048":false,"mailpoet_newsletter_max":false,"woocommerce_thumbnail":false,"woocommerce_single":false,"woocommerce_gallery_thumbnail":false,"shop_catalog":false,"shop_single":false,"shop_thumbnail":false},"uagb_author_info":{"display_name":"weijing","author_link":"http:\/\/www.weijing.co\/?author=4"},"uagb_comment_info":0,"uagb_excerpt":"Python \u7684 datetime \u6a21\u5757\u53ef\u4ee5\u81ea\u5b9a\u4e49\u65e5\u671f\u7684\u663e\u793a\u683c\u5f0f\uff0c\u800c\u4e14\u8fd8\u53ef\u4ee5\u5f88\u65b9\u4fbf\u5730\u5bf9\u65e5\u671f\u8fdb\u884c\u7b97\u672f\u8fd0\u7b97\uff0c\u6bd4\u5982\u589e&hellip;","_links":{"self":[{"href":"http:\/\/www.weijing.co\/index.php?rest_route=\/wp\/v2\/posts\/1635"}],"collection":[{"href":"http:\/\/www.weijing.co\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.weijing.co\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.weijing.co\/index.php?rest_route=\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"http:\/\/www.weijing.co\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1635"}],"version-history":[{"count":0,"href":"http:\/\/www.weijing.co\/index.php?rest_route=\/wp\/v2\/posts\/1635\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.weijing.co\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1635"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.weijing.co\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1635"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.weijing.co\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1635"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}