{"id":1126639,"date":"2025-01-08T20:03:06","date_gmt":"2025-01-08T12:03:06","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1126639.html"},"modified":"2025-01-08T20:03:08","modified_gmt":"2025-01-08T12:03:08","slug":"python%e5%a6%82%e4%bd%95%e5%88%a4%e6%96%ad%e4%b8%80%e5%b9%b4%e6%9c%80%e5%90%8e%e4%b8%80%e5%91%a8","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1126639.html","title":{"rendered":"Python\u5982\u4f55\u5224\u65ad\u4e00\u5e74\u6700\u540e\u4e00\u5468"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25090859\/15b2ad24-118e-4f5e-8c38-283a74d18c99.webp\" alt=\"Python\u5982\u4f55\u5224\u65ad\u4e00\u5e74\u6700\u540e\u4e00\u5468\" \/><\/p>\n<p><p> <strong>Python\u5224\u65ad\u4e00\u5e74\u6700\u540e\u4e00\u5468\u7684\u65b9\u6cd5\u4e3b\u8981\u6709\uff1a\u4f7f\u7528<code>datetime<\/code>\u6a21\u5757\u8ba1\u7b97\u3001\u7ed3\u5408ISO\u5468\u6570\u5224\u65ad\u3001\u5229\u7528<code>pandas<\/code>\u5904\u7406\u65f6\u95f4\u5e8f\u5217\u6570\u636e\u3002<\/strong> \u5728\u8fd9\u7bc7\u6587\u7ae0\u4e2d\uff0c\u6211\u4eec\u5c06\u63a2\u8ba8\u8fd9\u4e09\u79cd\u65b9\u6cd5\uff0c\u5e76\u8be6\u7ec6\u63cf\u8ff0\u5176\u4e2d\u7684\u4f7f\u7528<code>datetime<\/code>\u6a21\u5757\u8ba1\u7b97\u7684\u65b9\u6cd5\u3002<\/p>\n<\/p>\n<p><p>Python\u4e2d\u7684<code>datetime<\/code>\u6a21\u5757\u63d0\u4f9b\u4e86\u4e00\u79cd\u5904\u7406\u65e5\u671f\u548c\u65f6\u95f4\u7684\u6807\u51c6\u65b9\u5f0f\uff0c\u5b83\u4e0d\u4ec5\u652f\u6301\u65e5\u671f\u548c\u65f6\u95f4\u7684\u57fa\u672c\u64cd\u4f5c\uff0c\u8fd8\u53ef\u4ee5\u8fdb\u884c\u590d\u6742\u7684\u65e5\u671f\u8ba1\u7b97\u3002\u901a\u8fc7<code>datetime<\/code>\u6a21\u5757\uff0c\u6211\u4eec\u53ef\u4ee5\u8f7b\u677e\u5730\u5224\u65ad\u51fa\u67d0\u4e00\u5e74\u4e2d\u7684\u6700\u540e\u4e00\u5468\u3002<\/p>\n<\/p>\n<p><h2>\u4e00\u3001\u4f7f\u7528<code>datetime<\/code>\u6a21\u5757\u8ba1\u7b97<\/h2>\n<\/p>\n<p><h3>1\u3001\u83b7\u53d6\u5e74\u672b\u65e5\u671f<\/h3>\n<\/p>\n<p><p>\u8981\u5224\u65ad\u67d0\u4e00\u5e74\u7684\u6700\u540e\u4e00\u5468\uff0c\u9996\u5148\u9700\u8981\u786e\u5b9a\u8be5\u5e74\u7684\u6700\u540e\u4e00\u5929\uff0c\u537312\u670831\u65e5\u3002\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7<code>datetime<\/code>\u6a21\u5757\u6765\u83b7\u53d6\u8fd9\u4e00\u65e5\u671f\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from datetime import datetime<\/p>\n<p>year = 2023<\/p>\n<p>last_day_of_year = datetime(year, 12, 31)<\/p>\n<p>print(&quot;The last day of the year:&quot;, last_day_of_year)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>2\u3001\u8ba1\u7b97\u8be5\u65e5\u671f\u7684ISO\u5468\u6570<\/h3>\n<\/p>\n<p><p>\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528<code>isocalendar()<\/code>\u65b9\u6cd5\u5c06\u8be5\u65e5\u671f\u8f6c\u6362\u4e3aISO\u5468\u6570\u3002ISO 8601\u6807\u51c6\u89c4\u5b9a\u4e86\u4e00\u5e74\u4e2d\u7684\u5468\u6570\u548c\u5468\u51e0\uff0c\u5176\u4e2d\u6bcf\u5e74\u7684\u7b2c\u4e00\u5468\u662f\u5305\u542b1\u67084\u65e5\u7684\u90a3\u4e00\u5468\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">iso_calendar = last_day_of_year.isocalendar()<\/p>\n<p>iso_year, iso_week, iso_weekday = iso_calendar<\/p>\n<p>print(&quot;ISO year:&quot;, iso_year)<\/p>\n<p>print(&quot;ISO week:&quot;, iso_week)<\/p>\n<p>print(&quot;ISO weekday:&quot;, iso_weekday)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>3\u3001\u5224\u65ad\u662f\u5426\u4e3a\u6700\u540e\u4e00\u5468<\/h3>\n<\/p>\n<p><p>\u6839\u636eISO 8601\u6807\u51c6\uff0c\u5982\u679c\u67d0\u5e74\u7684\u6700\u540e\u4e00\u5929\u843d\u5728\u7b2c1\u5468\u6216\u7b2c52\u5468\uff0c\u90a3\u4e48\u8fd9\u4e00\u5929\u5c31\u5c5e\u4e8e\u8be5\u5e74\u7684\u6700\u540e\u4e00\u5468\u3002\u5426\u5219\uff0c\u5b83\u5c5e\u4e8e\u4e0b\u4e00\u5e74\u7684\u7b2c1\u5468\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">if iso_week == 52 or iso_week == 53:<\/p>\n<p>    print(f&quot;The last week of {year} is week {iso_week}.&quot;)<\/p>\n<p>else:<\/p>\n<p>    print(f&quot;The last week of {year} is not week {iso_week}.&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u8be6\u7ec6\u63cf\u8ff0\u4f7f\u7528<code>datetime<\/code>\u6a21\u5757\u8ba1\u7b97\u7684\u65b9\u6cd5<\/h3>\n<\/p>\n<p><p>\u4f7f\u7528<code>datetime<\/code>\u6a21\u5757\u8ba1\u7b97\u67d0\u4e00\u5e74\u6700\u540e\u4e00\u5468\u7684\u65b9\u6cd5\uff0c\u4e3b\u8981\u4f18\u52bf\u5728\u4e8e\u5176\u4ee3\u7801\u7b80\u6d01\u548c\u51c6\u786e\u6027\u9ad8\u3002\u901a\u8fc7\u83b7\u53d6\u5e74\u672b\u65e5\u671f\uff0c\u7136\u540e\u8f6c\u6362\u4e3aISO\u5468\u6570\uff0c\u6700\u540e\u5224\u65ad\u662f\u5426\u4e3a\u6700\u540e\u4e00\u5468\uff0c\u53ef\u4ee5\u786e\u4fdd\u6211\u4eec\u51c6\u786e\u5224\u65ad\u51fa\u8be5\u5e74\u7684\u6700\u540e\u4e00\u5468\u3002<\/p>\n<\/p>\n<p><p>\u4f8b\u5982\uff0c\u5047\u8bbe\u6211\u4eec\u9700\u8981\u5224\u65ad2023\u5e74\u7684\u6700\u540e\u4e00\u5468\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from datetime import datetime<\/p>\n<p>year = 2023<\/p>\n<p>last_day_of_year = datetime(year, 12, 31)<\/p>\n<p>iso_calendar = last_day_of_year.isocalendar()<\/p>\n<p>iso_year, iso_week, iso_weekday = iso_calendar<\/p>\n<p>if iso_week == 52 or iso_week == 53:<\/p>\n<p>    print(f&quot;The last week of {year} is week {iso_week}.&quot;)<\/p>\n<p>else:<\/p>\n<p>    print(f&quot;The last week of {year} is not week {iso_week}.&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u6bb5\u4ee3\u7801\u4e2d\uff0c\u6211\u4eec\u9996\u5148\u901a\u8fc7<code>datetime(year, 12, 31)<\/code>\u83b7\u53d62023\u5e74\u7684\u6700\u540e\u4e00\u5929\uff0c\u7136\u540e\u4f7f\u7528<code>isocalendar()<\/code>\u65b9\u6cd5\u5c06\u5176\u8f6c\u6362\u4e3aISO\u5468\u6570\u3002\u901a\u8fc7\u5224\u65ad<code>iso_week<\/code>\u662f\u5426\u4e3a52\u621653\uff0c\u53ef\u4ee5\u786e\u5b9a\u8fd9\u4e00\u5468\u662f\u5426\u4e3a2023\u5e74\u7684\u6700\u540e\u4e00\u5468\u3002<\/p>\n<\/p>\n<p><h2>\u4e8c\u3001\u7ed3\u5408ISO\u5468\u6570\u5224\u65ad<\/h2>\n<\/p>\n<p><h3>1\u3001\u83b7\u53d6ISO\u5468\u6570<\/h3>\n<\/p>\n<p><p>ISO 8601\u6807\u51c6\u89c4\u5b9a\u4e86\u4e00\u5e74\u4e2d\u7684\u5468\u6570\u548c\u5468\u51e0\u3002\u5229\u7528Python\u7684<code>datetime<\/code>\u6a21\u5757\uff0c\u6211\u4eec\u53ef\u4ee5\u5f88\u65b9\u4fbf\u5730\u83b7\u53d6\u67d0\u4e00\u5929\u7684ISO\u5468\u6570\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from datetime import date<\/p>\n<p>date_obj = date(2023, 12, 31)<\/p>\n<p>iso_calendar = date_obj.isocalendar()<\/p>\n<p>iso_year, iso_week, iso_weekday = iso_calendar<\/p>\n<p>print(&quot;ISO year:&quot;, iso_year)<\/p>\n<p>print(&quot;ISO week:&quot;, iso_week)<\/p>\n<p>print(&quot;ISO weekday:&quot;, iso_weekday)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>2\u3001\u5224\u65ad\u662f\u5426\u4e3a\u6700\u540e\u4e00\u5468<\/h3>\n<\/p>\n<p><p>\u6839\u636eISO 8601\u6807\u51c6\uff0c\u5982\u679c\u67d0\u5e74\u7684\u6700\u540e\u4e00\u5929\u843d\u5728\u7b2c1\u5468\u6216\u7b2c52\u5468\uff0c\u90a3\u4e48\u8fd9\u4e00\u5929\u5c31\u5c5e\u4e8e\u8be5\u5e74\u7684\u6700\u540e\u4e00\u5468\u3002\u5426\u5219\uff0c\u5b83\u5c5e\u4e8e\u4e0b\u4e00\u5e74\u7684\u7b2c1\u5468\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">if iso_week == 52 or iso_week == 53:<\/p>\n<p>    print(f&quot;The last week of {year} is week {iso_week}.&quot;)<\/p>\n<p>else:<\/p>\n<p>    print(f&quot;The last week of {year} is not week {iso_week}.&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u7ed3\u5408ISO\u5468\u6570\u7684\u65b9\u6cd5<\/h3>\n<\/p>\n<p><p>\u7ed3\u5408ISO\u5468\u6570\u7684\u65b9\u6cd5\u7c7b\u4f3c\u4e8e\u4f7f\u7528<code>datetime<\/code>\u6a21\u5757\u8ba1\u7b97\u7684\u65b9\u6cd5\uff0c\u4f46\u66f4\u52a0\u6ce8\u91cdISO 8601\u6807\u51c6\u3002\u901a\u8fc7\u83b7\u53d6\u5e74\u672b\u65e5\u671f\u7684ISO\u5468\u6570\uff0c\u53ef\u4ee5\u51c6\u786e\u5730\u5224\u65ad\u8be5\u5e74\u7684\u6700\u540e\u4e00\u5468\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from datetime import date<\/p>\n<p>year = 2023<\/p>\n<p>last_day_of_year = date(year, 12, 31)<\/p>\n<p>iso_calendar = last_day_of_year.isocalendar()<\/p>\n<p>iso_year, iso_week, iso_weekday = iso_calendar<\/p>\n<p>if iso_week == 52 or iso_week == 53:<\/p>\n<p>    print(f&quot;The last week of {year} is week {iso_week}.&quot;)<\/p>\n<p>else:<\/p>\n<p>    print(f&quot;The last week of {year} is not week {iso_week}.&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h2>\u4e09\u3001\u5229\u7528<code>pandas<\/code>\u5904\u7406\u65f6\u95f4\u5e8f\u5217\u6570\u636e<\/h2>\n<\/p>\n<p><h3>1\u3001\u5bfc\u5165<code>pandas<\/code>\u5e93<\/h3>\n<\/p>\n<p><p><code>pandas<\/code>\u662f\u4e00\u4e2a\u5f3a\u5927\u7684\u6570\u636e\u5904\u7406\u5e93\uff0c\u5c24\u5176\u64c5\u957f\u5904\u7406\u65f6\u95f4\u5e8f\u5217\u6570\u636e\u3002\u901a\u8fc7\u5bfc\u5165<code>pandas<\/code>\u5e93\uff0c\u6211\u4eec\u53ef\u4ee5\u65b9\u4fbf\u5730\u64cd\u4f5c\u65e5\u671f\u548c\u65f6\u95f4\u6570\u636e\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import pandas as pd<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>2\u3001\u751f\u6210\u65f6\u95f4\u5e8f\u5217\u6570\u636e<\/h3>\n<\/p>\n<p><p>\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528<code>pandas<\/code>\u751f\u6210\u67d0\u4e00\u5e74\u7684\u65f6\u95f4\u5e8f\u5217\u6570\u636e\uff0c\u7136\u540e\u901a\u8fc7<code>pd.Timestamp<\/code>\u83b7\u53d6\u8be5\u5e74\u7684\u6700\u540e\u4e00\u5929\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">year = 2023<\/p>\n<p>date_range = pd.date_range(start=f&#39;{year}-01-01&#39;, end=f&#39;{year}-12-31&#39;)<\/p>\n<p>last_day_of_year = pd.Timestamp(f&#39;{year}-12-31&#39;)<\/p>\n<p>print(&quot;The last day of the year:&quot;, last_day_of_year)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>3\u3001\u83b7\u53d6ISO\u5468\u6570<\/h3>\n<\/p>\n<p><p>\u901a\u8fc7<code>pd.Timestamp<\/code>\u7684<code>isocalendar()<\/code>\u65b9\u6cd5\uff0c\u6211\u4eec\u53ef\u4ee5\u83b7\u53d6\u8be5\u65e5\u671f\u7684ISO\u5468\u6570\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">iso_calendar = last_day_of_year.isocalendar()<\/p>\n<p>iso_year, iso_week, iso_weekday = iso_calendar<\/p>\n<p>print(&quot;ISO year:&quot;, iso_year)<\/p>\n<p>print(&quot;ISO week:&quot;, iso_week)<\/p>\n<p>print(&quot;ISO weekday:&quot;, iso_weekday)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>4\u3001\u5224\u65ad\u662f\u5426\u4e3a\u6700\u540e\u4e00\u5468<\/h3>\n<\/p>\n<p><p>\u6839\u636eISO 8601\u6807\u51c6\uff0c\u5224\u65ad\u8be5\u65e5\u671f\u662f\u5426\u5c5e\u4e8e\u6700\u540e\u4e00\u5468\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">if iso_week == 52 or iso_week == 53:<\/p>\n<p>    print(f&quot;The last week of {year} is week {iso_week}.&quot;)<\/p>\n<p>else:<\/p>\n<p>    print(f&quot;The last week of {year} is not week {iso_week}.&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u5229\u7528<code>pandas<\/code>\u5904\u7406\u65f6\u95f4\u5e8f\u5217\u6570\u636e\u7684\u65b9\u6cd5<\/h3>\n<\/p>\n<p><p>\u5229\u7528<code>pandas<\/code>\u5904\u7406\u65f6\u95f4\u5e8f\u5217\u6570\u636e\u7684\u65b9\u6cd5\uff0c\u9002\u7528\u4e8e\u5904\u7406\u5927\u89c4\u6a21\u65e5\u671f\u548c\u65f6\u95f4\u6570\u636e\u3002\u901a\u8fc7\u751f\u6210\u65f6\u95f4\u5e8f\u5217\u6570\u636e\uff0c\u53ef\u4ee5\u65b9\u4fbf\u5730\u83b7\u53d6\u67d0\u4e00\u5e74\u7684\u6700\u540e\u4e00\u5929\uff0c\u5e76\u901a\u8fc7<code>isocalendar()<\/code>\u65b9\u6cd5\u83b7\u53d6ISO\u5468\u6570\uff0c\u5224\u65ad\u662f\u5426\u4e3a\u6700\u540e\u4e00\u5468\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import pandas as pd<\/p>\n<p>year = 2023<\/p>\n<p>date_range = pd.date_range(start=f&#39;{year}-01-01&#39;, end=f&#39;{year}-12-31&#39;)<\/p>\n<p>last_day_of_year = pd.Timestamp(f&#39;{year}-12-31&#39;)<\/p>\n<p>iso_calendar = last_day_of_year.isocalendar()<\/p>\n<p>iso_year, iso_week, iso_weekday = iso_calendar<\/p>\n<p>if iso_week == 52 or iso_week == 53:<\/p>\n<p>    print(f&quot;The last week of {year} is week {iso_week}.&quot;)<\/p>\n<p>else:<\/p>\n<p>    print(f&quot;The last week of {year} is not week {iso_week}.&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h2>\u7ed3\u8bba<\/h2>\n<\/p>\n<p><p>\u901a\u8fc7\u672c\u6587\u7684\u4ecb\u7ecd\uff0c\u6211\u4eec\u8be6\u7ec6\u63a2\u8ba8\u4e86Python\u4e2d\u5224\u65ad\u4e00\u5e74\u6700\u540e\u4e00\u5468\u7684\u4e09\u79cd\u65b9\u6cd5\uff1a<strong>\u4f7f\u7528<code>datetime<\/code>\u6a21\u5757\u8ba1\u7b97\u3001\u7ed3\u5408ISO\u5468\u6570\u5224\u65ad\u3001\u5229\u7528<code>pandas<\/code>\u5904\u7406\u65f6\u95f4\u5e8f\u5217\u6570\u636e<\/strong>\u3002\u6bcf\u79cd\u65b9\u6cd5\u90fd\u6709\u5176\u72ec\u7279\u7684\u4f18\u52bf\uff0c\u5177\u4f53\u9009\u62e9\u54ea\u79cd\u65b9\u6cd5\u53d6\u51b3\u4e8e\u5b9e\u9645\u9700\u6c42\u548c\u5e94\u7528\u573a\u666f\u3002<\/p>\n<\/p>\n<p><p>\u603b\u7684\u6765\u8bf4\uff0c<strong>\u4f7f\u7528<code>datetime<\/code>\u6a21\u5757\u8ba1\u7b97<\/strong>\u7684\u65b9\u6cd5\u4ee3\u7801\u7b80\u6d01\u3001\u51c6\u786e\u6027\u9ad8\uff0c\u9002\u5408\u4e00\u822c\u60c5\u51b5\uff1b<strong>\u7ed3\u5408ISO\u5468\u6570\u5224\u65ad<\/strong>\u7684\u65b9\u6cd5\u66f4\u7b26\u5408ISO 8601\u6807\u51c6\uff0c\u9002\u5408\u9700\u8981\u4e25\u683c\u9075\u5b88\u6807\u51c6\u7684\u573a\u666f\uff1b\u800c<strong>\u5229\u7528<code>pandas<\/code>\u5904\u7406\u65f6\u95f4\u5e8f\u5217\u6570\u636e<\/strong>\u7684\u65b9\u6cd5\u5219\u9002\u7528\u4e8e\u5904\u7406\u5927\u89c4\u6a21\u65e5\u671f\u548c\u65f6\u95f4\u6570\u636e\u7684\u60c5\u51b5\u3002<\/p>\n<\/p>\n<p><p>\u65e0\u8bba\u9009\u62e9\u54ea\u79cd\u65b9\u6cd5\uff0c\u90fd\u53ef\u4ee5\u51c6\u786e\u5730\u5224\u65ad\u51fa\u67d0\u4e00\u5e74\u7684\u6700\u540e\u4e00\u5468\u3002\u5e0c\u671b\u672c\u6587\u80fd\u5bf9\u60a8\u5728Python\u7f16\u7a0b\u4e2d\u5904\u7406\u65e5\u671f\u548c\u65f6\u95f4\u95ee\u9898\u6709\u6240\u5e2e\u52a9\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u5728Python\u4e2d\u786e\u5b9a\u4e00\u5e74\u6700\u540e\u4e00\u5468\u7684\u5f00\u59cb\u548c\u7ed3\u675f\u65e5\u671f\uff1f<\/strong><br \/>\u5728Python\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528<code>datetime<\/code>\u6a21\u5757\u6765\u8ba1\u7b97\u4e00\u5e74\u6700\u540e\u4e00\u5468\u7684\u5f00\u59cb\u548c\u7ed3\u675f\u65e5\u671f\u3002\u9996\u5148\u83b7\u53d6\u8be5\u5e74\u7684\u6700\u540e\u4e00\u5929\uff0c\u7136\u540e\u6839\u636e\u8be5\u5929\u662f\u661f\u671f\u51e0\uff0c\u63a8\u7b97\u51fa\u6700\u540e\u4e00\u5468\u7684\u5f00\u59cb\u548c\u7ed3\u675f\u65e5\u671f\u3002\u5177\u4f53\u5b9e\u73b0\u53ef\u4ee5\u4f7f\u7528<code>timedelta<\/code>\u6765\u8fdb\u884c\u65e5\u671f\u7684\u52a0\u51cf\u8fd0\u7b97\u3002<\/p>\n<p><strong>\u4f7f\u7528Python\u5224\u65ad\u4e00\u5e74\u6700\u540e\u4e00\u5468\u7684\u5468\u6570\u6709\u4ec0\u4e48\u65b9\u6cd5\uff1f<\/strong><br \/>Python\u53ef\u4ee5\u901a\u8fc7<code>isocalendar()<\/code>\u65b9\u6cd5\u6765\u83b7\u53d6\u65e5\u671f\u7684ISO\u5468\u6570\u3002\u901a\u8fc7\u83b7\u53d6\u4e00\u5e74\u6700\u540e\u4e00\u5929\u7684\u65e5\u671f\uff0c\u8c03\u7528<code>isocalendar()<\/code>\u53ef\u4ee5\u76f4\u63a5\u5f97\u5230\u8be5\u65e5\u671f\u5bf9\u5e94\u7684\u5468\u6570\u3002\u8fd9\u6837\u4e0d\u4ec5\u65b9\u4fbf\uff0c\u4e5f\u907f\u514d\u4e86\u624b\u52a8\u8ba1\u7b97\u7684\u590d\u6742\u6027\u3002<\/p>\n<p><strong>\u5728\u5904\u7406\u8de8\u5e74\u6570\u636e\u65f6\uff0c\u5982\u4f55\u786e\u4fdd\u8ba1\u7b97\u6700\u540e\u4e00\u5468\u7684\u51c6\u786e\u6027\uff1f<\/strong><br \/>\u5728\u8fdb\u884c\u8de8\u5e74\u6570\u636e\u5904\u7406\u65f6\uff0c\u9700\u8981\u7279\u522b\u6ce8\u610f\u5e74\u4efd\u7684\u53d8\u5316\u3002\u5728\u8ba1\u7b97\u4e00\u5e74\u6700\u540e\u4e00\u5468\u65f6\uff0c\u53ef\u4ee5\u4f7f\u7528<code>datetime<\/code>\u6a21\u5757\u7684<code>date<\/code>\u7c7b\u6765\u786e\u4fdd\u83b7\u53d6\u7684\u65e5\u671f\u662f\u51c6\u786e\u7684\u3002\u540c\u65f6\uff0c\u786e\u8ba4\u6240\u4f7f\u7528\u7684\u5468\u7684\u6807\u51c6\uff0c\u4f8b\u5982ISO\u5468\u6807\u51c6\u6216\u7f8e\u56fd\u5468\u6807\u51c6\uff0c\u4ee5\u907f\u514d\u56e0\u4e0d\u540c\u6807\u51c6\u5bfc\u81f4\u7684\u8ba1\u7b97\u8bef\u5dee\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"Python\u5224\u65ad\u4e00\u5e74\u6700\u540e\u4e00\u5468\u7684\u65b9\u6cd5\u4e3b\u8981\u6709\uff1a\u4f7f\u7528datetime\u6a21\u5757\u8ba1\u7b97\u3001\u7ed3\u5408ISO\u5468\u6570\u5224\u65ad\u3001\u5229\u7528pandas\u5904 [&hellip;]","protected":false},"author":3,"featured_media":1126644,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[37],"tags":[],"acf":[],"_links":{"self":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1126639"}],"collection":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/comments?post=1126639"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1126639\/revisions"}],"predecessor-version":[{"id":1126645,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1126639\/revisions\/1126645"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1126644"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1126639"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1126639"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1126639"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}