{"id":2530,"date":"2025-10-10T12:35:45","date_gmt":"2025-10-10T03:05:45","guid":{"rendered":"https:\/\/softasia.jp\/blog\/?p=2530"},"modified":"2025-10-10T12:35:45","modified_gmt":"2025-10-10T03:05:45","slug":"python%e5%85%a5%e9%96%80%ef%bc%81%e6%97%a5%e4%bb%98%e3%81%a8%e6%99%82%e5%88%bb%e3%82%92%e7%b0%a1%e5%8d%98%e6%93%8d%e4%bd%9c%ef%bc%81datetime%e3%83%a2%e3%82%b8%e3%83%a5%e3%83%bc%e3%83%ab%e3%81%ae","status":"publish","type":"post","link":"https:\/\/softasia.jp\/blog\/offshore\/2530\/","title":{"rendered":"Python\u5165\u9580\uff01\u65e5\u4ed8\u3068\u6642\u523b\u3092\u7c21\u5358\u64cd\u4f5c\uff01datetime\u30e2\u30b8\u30e5\u30fc\u30eb\u306e\u4f7f\u3044\u65b9\u3092\u5fb9\u5e95\u89e3\u8aac\uff01"},"content":{"rendered":"<p><img loading=\"lazy\" class=\"size-medium wp-image-2585 aligncenter\" src=\"https:\/\/softasia.jp\/blog\/wp-content\/uploads\/2025\/09\/\u540d\u79f0\u672a\u8a2d\u5b9a\u306e\u30c7\u30b6\u30a4\u30f3-300x169.png\" alt=\"\" width=\"300\" height=\"169\" srcset=\"https:\/\/softasia.jp\/blog\/wp-content\/uploads\/2025\/09\/\u540d\u79f0\u672a\u8a2d\u5b9a\u306e\u30c7\u30b6\u30a4\u30f3-300x169.png 300w, https:\/\/softasia.jp\/blog\/wp-content\/uploads\/2025\/09\/\u540d\u79f0\u672a\u8a2d\u5b9a\u306e\u30c7\u30b6\u30a4\u30f3-1024x576.png 1024w, https:\/\/softasia.jp\/blog\/wp-content\/uploads\/2025\/09\/\u540d\u79f0\u672a\u8a2d\u5b9a\u306e\u30c7\u30b6\u30a4\u30f3-768x432.png 768w, https:\/\/softasia.jp\/blog\/wp-content\/uploads\/2025\/09\/\u540d\u79f0\u672a\u8a2d\u5b9a\u306e\u30c7\u30b6\u30a4\u30f3-1536x864.png 1536w, https:\/\/softasia.jp\/blog\/wp-content\/uploads\/2025\/09\/\u540d\u79f0\u672a\u8a2d\u5b9a\u306e\u30c7\u30b6\u30a4\u30f3.png 2048w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400;\">Python\u3067\u958b\u767a\u3084\u5206\u6790\u3092\u3057\u3066\u3044\u308b\u3068\u3001\u5fc5\u305a\u767b\u5834\u3059\u308b\u306e\u304c<strong><span style=\"text-decoration: underline;\">\u300c\u65e5\u4ed8\u300d<\/span><\/strong>\u3068<span style=\"text-decoration: underline;\"><strong>\u300c\u6642\u523b\u300d<\/strong><\/span>\u306e\u6271\u3044\u3067\u3059\u3002\u30ed\u30b0\u306e\u8a18\u9332\u3001\u30d5\u30a1\u30a4\u30eb\u540d\u306b\u30bf\u30a4\u30e0\u30b9\u30bf\u30f3\u30d7\u3092\u4ed8\u3051\u308b\u3001\u30c7\u30fc\u30bf\u5206\u6790\u3067\u65e5\u4ed8\u3092\u57fa\u6e96\u306b\u30b0\u30eb\u30fc\u30d4\u30f3\u30b0\u3059\u308b\u3001\u306a\u3069\u6d3b\u7528\u30b7\u30fc\u30f3\u306f\u7121\u6570\u306b\u3042\u308a\u307e\u3059\u3002<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400;\"><span style=\"color: #ff0000;\">datetime\u30e2\u30b8\u30e5\u30fc\u30eb<\/span>\u306f\u3001<span style=\"text-decoration: underline;\">\u6642\u523b\u306e\u53d6\u5f97\u30fb\u65e5\u4ed8\u8a08\u7b97\u30fb\u30d5\u30a9\u30fc\u30de\u30c3\u30c8\u5909\u63db\u30fb\u30bf\u30a4\u30e0\u30be\u30fc\u30f3\u5bfe\u5fdc\u306a\u3069\u3001\u65e5\u5e38\u7684\u306b\u4f7f\u3046\u65e5\u6642\u51e6\u7406\u30921\u3064\u306e\u30e2\u30b8\u30e5\u30fc\u30eb<\/span>\u3067\u5b8c\u7d50\u3067\u304d\u307e\u3059\u3002<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400;\">\u4f8b\u3048\u3070\u3001<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\"><strong>\u4eca\u65e5\u304b\u30891\u9031\u9593\u5f8c\u30fb1\u304b\u6708\u524d\u306e\u65e5\u4ed8\u3092\u6c42\u3081\u305f\u3044<\/strong><\/li>\n<li style=\"font-weight: 400;\"><strong>2\u3064\u306e\u65e5\u4ed8\u306e\u5dee\uff08\u65e5\u6570\u30fb\u6642\u9593\uff09\u3092\u77e5\u308a\u305f\u3044<\/strong><\/li>\n<li style=\"font-weight: 400;\"><strong>\u30bf\u30a4\u30e0\u30be\u30fc\u30f3\u3092\u8003\u616e\u3057\u305f\u30b0\u30ed\u30fc\u30d0\u30eb\u306a\u30a2\u30d7\u30ea\u3092\u4f5c\u308a\u305f\u3044<\/strong><\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400;\">\u3068\u3044\u3063\u305f\u30cb\u30fc\u30ba\u306b\u3059\u3079\u3066\u5fdc\u3048\u3066\u304f\u308c\u308b\u306e\u304cdatetime\u3067\u3059\u3002<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400;\">\u3053\u306e\u8a18\u4e8b\u3067\u306f\u3001Python\u6a19\u6e96\u30e9\u30a4\u30d6\u30e9\u30ea\u306edatetime\u30e2\u30b8\u30e5\u30fc\u30eb\u3092\u4f7f\u3063\u3066\u300c\u65e5\u4ed8\u300d\u3068\u300c\u6642\u523b\u300d\u3092\u6271\u3046\u65b9\u6cd5\u3092<\/span><span style=\"font-weight: 400;\">\u3001Python\u521d\u5fc3\u8005\u3067\u3082\u8ff7\u308f\u305a\u4f7f\u3048\u308b\u3088\u3046\u3001\u57fa\u672c\u304b\u3089\u5fdc\u7528\u307e\u3067\u3092\u4f53\u7cfb\u7684\u306b\u89e3\u8aac\u3057\u3066\u3044\u304d\u307e\u3059\u3002<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400;\">\u3053\u306e\u8a18\u4e8b\u3067\u308f\u304b\u308b\u3053\u3068<\/span><\/p>\n<ul>\n<li><strong> datetime\u30e2\u30b8\u30e5\u30fc\u30eb\u306e\u57fa\u672c\u69cb\u9020<\/strong><\/li>\n<li><strong> \u65e5\u4ed8\u30fb\u6642\u523b\u306e\u53d6\u5f97\u30fb\u8868\u793a\u30fb\u5909\u63db\u65b9\u6cd5<\/strong><\/li>\n<li><strong> timedelta\u306b\u3088\u308b\u6642\u9593\u8a08\u7b97<\/strong><\/li>\n<li><strong> \u5b9f\u52d9\u3067\u5f79\u7acb\u3064\u5fdc\u7528\u4f8b\uff08\u30ed\u30b0\u51e6\u7406\u3001\u30b9\u30b1\u30b8\u30e5\u30fc\u30ea\u30f3\u30b0\u306a\u3069\uff09<\/strong><\/li>\n<li><strong> \u3088\u304f\u3042\u308b\u30a8\u30e9\u30fc\u3068\u305d\u306e\u5bfe\u51e6\u6cd5<\/strong><\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<div id=\"toc_container\" class=\"no_bullets\"><p class=\"toc_title\">\u76ee\u6b21<\/p><ul class=\"toc_list\"><li><a href=\"#datetime\"><span class=\"toc_number toc_depth_1\">1<\/span> datetime\u30e2\u30b8\u30e5\u30fc\u30eb\u3068\u306f<\/a><ul><li><a href=\"#i\"><span class=\"toc_number toc_depth_2\">1.1<\/span> \u73fe\u5728\u306e\u65e5\u4ed8\u30fb\u6642\u523b\u3092\u53d6\u5f97\u3059\u308b\u65b9\u6cd5<\/a><\/li><li><a href=\"#strftime_strptime\"><span class=\"toc_number toc_depth_2\">1.2<\/span> \u65e5\u4ed8\u30fb\u6642\u523b\u306e\u30d5\u30a9\u30fc\u30de\u30c3\u30c8\u5909\u63db\uff08strftime \/ strptime\uff09<\/a><\/li><\/ul><\/li><li><a href=\"#i-2\"><span class=\"toc_number toc_depth_1\">2<\/span> \u5b9f\u52d9\u3067\u5f79\u7acb\u3064\u5fdc\u7528\u4f8b<\/a><\/li><li><a href=\"#i-3\"><span class=\"toc_number toc_depth_1\">3<\/span> \u3088\u304f\u3042\u308b\u30a8\u30e9\u30fc\u3068\u5bfe\u51e6\u6cd5<\/a><\/li><li><a href=\"#i-4\"><span class=\"toc_number toc_depth_1\">4<\/span> \u6a5f\u68b0\u5b66\u7fd2\u3068\u306e\u95a2\u9023\u6027<\/a><\/li><li><a href=\"#i-5\"><span class=\"toc_number toc_depth_1\">5<\/span> \u307e\u3068\u3081<\/a><\/li><\/ul><\/div>\n<h2><span id=\"datetime\"><span style=\"font-weight: 400;\">datetime\u30e2\u30b8\u30e5\u30fc\u30eb\u3068\u306f<\/span><\/span><\/h2>\n<p><img loading=\"lazy\" class=\"size-medium wp-image-2588 aligncenter\" src=\"https:\/\/softasia.jp\/blog\/wp-content\/uploads\/2025\/09\/SOFT-_ASIA-39-300x200.png\" alt=\"\" width=\"300\" height=\"200\" srcset=\"https:\/\/softasia.jp\/blog\/wp-content\/uploads\/2025\/09\/SOFT-_ASIA-39-300x200.png 300w, https:\/\/softasia.jp\/blog\/wp-content\/uploads\/2025\/09\/SOFT-_ASIA-39.png 640w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400;\"><span style=\"text-decoration: underline;\">Python\u306edatetime\u30e2\u30b8\u30e5\u30fc\u30eb\u306f\u3001\u65e5\u4ed8\u3084\u6642\u523b\u3092\u6271\u3046\u305f\u3081\u306e\u6a19\u6e96\u30e9\u30a4\u30d6\u30e9\u30ea\u3067\u3059<\/span>\u3002\u5916\u90e8\u30d1\u30c3\u30b1\u30fc\u30b8\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b\u5fc5\u8981\u304c\u306a\u304f\u3001\u3059\u3050\u306b\u4f7f\u3048\u308b\u306e\u304c\u9b45\u529b\u3067\u3059\u3002<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400; color: #0000ff;\">import datetime<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400;\">\u3053\u306e\u30e2\u30b8\u30e5\u30fc\u30eb\u306b\u306f\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u4e3b\u8981\u30af\u30e9\u30b9\u304c\u542b\u307e\u308c\u3066\u3044\u307e\u3059<\/span><\/p>\n<table style=\"border-collapse: collapse; width: 100%; height: 115px;\">\n<tbody>\n<tr style=\"height: 23px;\">\n<td style=\"width: 50%; height: 23px;\"><strong>\u30af\u30e9\u30b9\u540d<\/strong><\/td>\n<td style=\"width: 50%; height: 23px;\"><strong>\u5f79\u5272<\/strong><\/td>\n<\/tr>\n<tr style=\"height: 23px;\">\n<td style=\"width: 50%; height: 23px;\"><strong>datetime.date<\/strong><\/td>\n<td style=\"width: 50%; height: 23px;\"><span style=\"font-weight: 400;\">\u5e74\u30fb\u6708\u30fb\u65e5\u3092\u6271\u3046<\/span><\/td>\n<\/tr>\n<tr style=\"height: 23px;\">\n<td style=\"width: 50%; height: 23px;\"><strong>datetime.time<\/strong><\/td>\n<td style=\"width: 50%; height: 23px;\"><span style=\"font-weight: 400;\">\u6642\u30fb\u5206\u30fb\u79d2\u3092\u6271\u3046<\/span><\/td>\n<\/tr>\n<tr style=\"height: 23px;\">\n<td style=\"width: 50%; height: 23px;\"><strong>datetime.datetime<\/strong><\/td>\n<td style=\"width: 50%; height: 23px;\"><span style=\"font-weight: 400;\">\u65e5\u4ed8\uff0b\u6642\u523b\u3092\u307e\u3068\u3081\u3066<\/span><\/td>\n<\/tr>\n<tr style=\"height: 23px;\">\n<td style=\"width: 50%; height: 23px;\"><strong>datetime.timedelta<\/strong><\/td>\n<td style=\"width: 50%; height: 23px;\"><span style=\"font-weight: 400;\">\u6642\u9593\u306e\u5dee\u5206\u3092\u8868\u73fe\u3059\u308b<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<h3><span id=\"i\"><span style=\"font-weight: 400;\">\u73fe\u5728\u306e\u65e5\u4ed8\u30fb\u6642\u523b\u3092\u53d6\u5f97\u3059\u308b\u65b9\u6cd5<\/span><\/span><\/h3>\n<p><span style=\"font-weight: 400;\">\u6700\u3082\u57fa\u672c\u7684\u306a\u4f7f\u3044\u65b9\u306f\u3001\u73fe\u5728\u306e\u65e5\u6642\u3092\u53d6\u5f97\u3059\u308b\u3053\u3068\u3067\u3059\u3002<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400; color: #0000ff;\">from datetime import datetime<\/span><\/p>\n<p><span style=\"font-weight: 400; color: #0000ff;\">now = datetime.now()<\/span><\/p>\n<p><span style=\"font-weight: 400;\"><span style=\"color: #0000ff;\">print(now)\u00a0<\/span> #\u00a0 2025-09-10 22:22:00.123456<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400;\"><span style=\"color: #ff0000;\">datetime.now()<\/span>\u3067\u73fe\u5728\u306e\u65e5\u6642\u3092\u53d6\u5f97\u3067\u304d\u307e\u3059\u3002\u30df\u30ea\u79d2\u307e\u3067\u6271\u3048\u308b\u305f\u3081\u30ed\u30b0\u51fa\u529b\u306a\u3069\u306b\u4fbf\u5229\u3067\u3059\u3002<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><b>\u65e5\u4ed8\u3060\u3051\u3092\u53d6\u5f97\u3057\u305f\u3044\u5834\u5408<\/b><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400; color: #0000ff;\">today = datetime.today().date()<\/span><\/p>\n<p><span style=\"font-weight: 400;\"><span style=\"color: #0000ff;\">print(today)\u00a0<\/span> #\u00a0 2025-09-10<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400;\"><span style=\"color: #ff0000;\">date.today()<\/span>\u3067\u65e5\u4ed8\u90e8\u5206\u3060\u3051\u3092\u53d6\u5f97\u53ef\u80fd\u3067\u3059\u3002<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><b>\u6642\u523b\u3060\u3051\u3092\u53d6\u5f97\u3057\u305f\u3044\u5834\u5408<\/b><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400; color: #0000ff;\">current_time = datetime.now().time()<\/span><\/p>\n<p><span style=\"font-weight: 400;\"><span style=\"color: #0000ff;\">print(current_time)\u00a0<\/span> # 22:22:00.123456<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400;\">\u897f\u66a6\u30fb\u6708\u30fb\u65e5\u30fb\u6642\u30fb\u5206\u30fb\u79d2\u3092\u5f15\u6570\u306b\u4e0e\u3048\u3066\u4efb\u610f\u306e\u65e5\u6642\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u4f5c\u6210\u3067\u304d\u307e\u3059\u3002<\/span><\/p>\n<p>&nbsp;<\/p>\n<h3><span id=\"strftime_strptime\"><span style=\"font-weight: 400;\">\u65e5\u4ed8\u30fb\u6642\u523b\u306e\u30d5\u30a9\u30fc\u30de\u30c3\u30c8\u5909\u63db\uff08strftime \/ strptime\uff09<\/span><\/span><\/h3>\n<p><span style=\"font-weight: 400;\">Python\u3067\u306f\u3001\u65e5\u4ed8\u3084\u6642\u523b\u3092\u6587\u5b57\u5217\u306b\u5909\u63db\u3057\u305f\u308a\u3001\u9006\u306b\u6587\u5b57\u5217\u304b\u3089\u65e5\u6642\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u751f\u6210\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/span><\/p>\n<p><span style=\"font-weight: 400;\"><span style=\"color: #ff0000;\">strftime\u30e1\u30bd\u30c3\u30c9<\/span>\u3067\u81ea\u7531\u306a\u30d5\u30a9\u30fc\u30de\u30c3\u30c8\u306b\u6574\u5f62\u3067\u304d\u307e\u3059\u3002<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400;\">\u4f8b\uff1a<\/span><\/p>\n<ul>\n<li><span style=\"font-weight: 400;\"><strong>%Y<\/strong>\uff1a\u897f\u66a64\u6841<\/span><\/li>\n<li><span style=\"font-weight: 400;\"><strong>%m<\/strong>\uff1a\u6708\uff0801\u301c12\uff09<\/span><\/li>\n<li><span style=\"font-weight: 400;\"><strong>%d<\/strong>\uff1a\u65e5<\/span><\/li>\n<li><span style=\"font-weight: 400;\"><strong>%H<\/strong>\uff1a\u6642\uff0824\u6642\u9593\u5236\uff09<\/span><\/li>\n<li><span style=\"font-weight: 400;\"><strong>%M<\/strong>\uff1a\u5206<\/span><\/li>\n<li><span style=\"font-weight: 400;\"><strong>%S<\/strong>\uff1a\u79d2<\/span><\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400;\">\u6587\u5b57\u5217 \u2192 datetime<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><b>\u65e5\u4ed8\u3092\u6587\u5b57\u5217\u306b\u5909\u63db\uff08strftime\uff09<\/b><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400; color: #0000ff;\">formatted = now.strftime(&#8216;%Y\/%m\/%d %H:%M:%S&#8217;)<\/span><\/p>\n<p><span style=\"font-weight: 400;\"><span style=\"color: #0000ff;\">print(formatted)<\/span>\u00a0 # 2025\/09\/10 22:22:00<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><b>\u6587\u5b57\u5217\u3092\u65e5\u4ed8\u306b\u5909\u63db\uff08strptime\uff09<\/b><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400; color: #0000ff;\">date_str = &#8216;2025-09-10 22:22:00&#8217;<\/span><\/p>\n<p><span style=\"font-weight: 400; color: #0000ff;\">parsed = datetime.strptime(date_str, &#8216;%Y-%m-%d %H:%M:%S&#8217;)<\/span><\/p>\n<p><span style=\"font-weight: 400;\"><span style=\"color: #0000ff;\">print(parsed)<\/span>\u00a0 # datetime\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3068\u3057\u3066\u6271\u3048\u308b<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400;\"><span style=\"text-decoration: underline;\">strptime\u3092\u4f7f\u3048\u3070\u6587\u5b57\u5217\u304b\u3089datetime\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u4f5c\u6210\u3067\u304d\u307e\u3059<\/span>\u3002\u30c7\u30fc\u30bf\u5206\u6790\u3067CSV\u304b\u3089\u8aad\u307f\u8fbc\u3093\u3060\u65e5\u4ed8\u3092\u5909\u63db\u3059\u308b\u969b\u306b\u4fbf\u5229\u3067\u3059\u3002<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><b>\u65e5\u4ed8\u306e\u52a0\u7b97\u30fb\u6e1b\u7b97\uff08timedelta\uff09<\/b><\/p>\n<p><span style=\"font-weight: 400;\"><span style=\"color: #ff0000;\">timedelta<\/span>\u3092\u4f7f\u3048\u3070\u3001\u65e5\u4ed8\u3084\u6642\u523b\u306e\u8a08\u7b97\u304c\u7c21\u5358\u306b\u3067\u304d\u307e\u3059\u3002<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400;\">1\u9031\u9593\u5f8c\u306e\u65e5\u4ed8\u3092\u53d6\u5f97<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400; color: #0000ff;\">from datetime import timedelta<\/span><\/p>\n<p><span style=\"font-weight: 400; color: #0000ff;\">one_week_later = now + timedelta(days=7)<\/span><\/p>\n<p><span style=\"font-weight: 400; color: #0000ff;\">print(one_week_later)<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400;\">3\u6642\u9593\u524d\u306e\u6642\u523b\u3092\u53d6\u5f97<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400; color: #0000ff;\">three_hours_ago = now &#8211; timedelta(hours=3)<\/span><\/p>\n<p><span style=\"font-weight: 400; color: #0000ff;\">print(three_hours_ago)<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400;\"><span style=\"color: #ff0000;\">delta.days<\/span>\u3067\u65e5\u6570\u5dee\u3092\u7c21\u5358\u306b\u53d6\u5f97\u53ef\u80fd\u3067\u3059\u3002<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><strong>\u30bf\u30a4\u30e0\u30be\u30fc\u30f3\u3092\u6271\u3046<\/strong><\/p>\n<p><span style=\"font-weight: 400;\">Python 3.9\u4ee5\u964d\u3067\u306fzoneinfo\u304c\u6a19\u6e96\u642d\u8f09\u3055\u308c\u3001\u30bf\u30a4\u30e0\u30be\u30fc\u30f3\u306e\u6271\u3044\u304c\u3088\u308a\u7c21\u5358\u306b\u306a\u308a\u307e\u3057\u305f\u3002<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400; color: #0000ff;\">from datetime import datetime<\/span><\/p>\n<p><span style=\"font-weight: 400; color: #0000ff;\">from zoneinfo import ZoneInfo<\/span><\/p>\n<p><span style=\"font-weight: 400; color: #0000ff;\">dt_tokyo = datetime.now(ZoneInfo(&#8216;Asia\/Tokyo&#8217;))<\/span><\/p>\n<p><span style=\"font-weight: 400; color: #0000ff;\">dt_utc = datetime.now(ZoneInfo(&#8216;UTC&#8217;))<\/span><\/p>\n<p><span style=\"font-weight: 400; color: #0000ff;\">print(dt_tokyo)<\/span><\/p>\n<p><span style=\"font-weight: 400; color: #0000ff;\">print(dt_utc)<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400;\">\u30ed\u30b0\u3084\u6d77\u5916\u30b5\u30fc\u30d3\u30b9\u9023\u643a\u3067\u306fUTC\u57fa\u6e96\u3067\u8a18\u9332\u3057\u3001\u8868\u793a\u6642\u306b\u30ed\u30fc\u30ab\u30eb\u30bf\u30a4\u30e0\u306b\u5909\u63db\u3059\u308b\u904b\u7528\u304c\u4e00\u822c\u7684\u3067\u3059\u3002<\/span><\/p>\n<p>&nbsp;<\/p>\n<h2><span id=\"i-2\"><span style=\"font-weight: 400;\">\u5b9f\u52d9\u3067\u5f79\u7acb\u3064\u5fdc\u7528\u4f8b<\/span><\/span><\/h2>\n<p><img loading=\"lazy\" class=\"size-medium wp-image-2590 aligncenter\" src=\"https:\/\/softasia.jp\/blog\/wp-content\/uploads\/2025\/09\/SOFT-_ASIA-40-300x200.png\" alt=\"\" width=\"300\" height=\"200\" srcset=\"https:\/\/softasia.jp\/blog\/wp-content\/uploads\/2025\/09\/SOFT-_ASIA-40-300x200.png 300w, https:\/\/softasia.jp\/blog\/wp-content\/uploads\/2025\/09\/SOFT-_ASIA-40.png 640w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p><strong>\u30ed\u30b0\u30d5\u30a1\u30a4\u30eb\u306e\u30bf\u30a4\u30e0\u30b9\u30bf\u30f3\u30d7\u51e6\u7406<\/strong><\/p>\n<p><span style=\"font-weight: 400;\">\u30ed\u30b0\u306e\u8a18\u9332\u306b\u65e5\u6642\u3092\u4ed8\u3051\u308b\u3053\u3068\u3067\u3001\u5f8c\u304b\u3089\u306e\u5206\u6790\u304c\u5bb9\u6613\u306b\u306a\u308a\u307e\u3059\u3002<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400; color: #0000ff;\">def log_message(message):<\/span><\/p>\n<p><span style=\"font-weight: 400; color: #0000ff;\">\u00a0\u00a0\u00a0\u00a0timestamp = datetime.now().strftime(&#8216;%Y-%m-%d %H:%M:%S&#8217;)<\/span><\/p>\n<p><span style=\"font-weight: 400; color: #0000ff;\">\u00a0\u00a0\u00a0\u00a0print(f'[{timestamp}] {message}&#8217;)<\/span><\/p>\n<p><span style=\"font-weight: 400; color: #0000ff;\">log_message(&#8220;\u51e6\u7406\u304c\u5b8c\u4e86\u3057\u307e\u3057\u305f&#8221;)<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><strong>\u30b9\u30b1\u30b8\u30e5\u30fc\u30eb\u7ba1\u7406\u30a2\u30d7\u30ea\u3067\u306e\u6d3b\u7528<\/strong><\/p>\n<p><span style=\"font-weight: 400;\">\u30e6\u30fc\u30b6\u30fc\u304c\u6307\u5b9a\u3057\u305f\u65e5\u4ed8\u304b\u3089\u3001\u6b21\u56de\u306e\u4e88\u5b9a\u3092\u81ea\u52d5\u8a08\u7b97\u3059\u308b\u4f8b<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400; color: #0000ff;\">def next_meeting(date_str):<\/span><\/p>\n<p><span style=\"font-weight: 400; color: #0000ff;\">\u00a0\u00a0\u00a0\u00a0base_date = datetime.strptime(date_str, &#8216;%Y-%m-%d&#8217;)<\/span><\/p>\n<p><span style=\"font-weight: 400; color: #0000ff;\">\u00a0\u00a0\u00a0\u00a0next_date = base_date + timedelta(days=14)<\/span><\/p>\n<p><span style=\"font-weight: 400; color: #0000ff;\">\u00a0\u00a0\u00a0\u00a0return next_date.strftime(&#8216;%Y-%m-%d&#8217;)<\/span><\/p>\n<p><span style=\"font-weight: 400;\"><span style=\"color: #0000ff;\">print(next_meeting(&#8216;2025-09-10&#8217;))\u00a0<\/span> #\u00a0 2025-09-24<\/span><\/p>\n<p>&nbsp;<\/p>\n<h2><span id=\"i-3\"><span style=\"font-weight: 400;\">\u3088\u304f\u3042\u308b\u30a8\u30e9\u30fc\u3068\u5bfe\u51e6\u6cd5<\/span><\/span><\/h2>\n<p><img loading=\"lazy\" class=\"size-medium wp-image-2578 aligncenter\" src=\"https:\/\/softasia.jp\/blog\/wp-content\/uploads\/2025\/09\/SOFT-_ASIA-37-300x200.png\" alt=\"\" width=\"300\" height=\"200\" srcset=\"https:\/\/softasia.jp\/blog\/wp-content\/uploads\/2025\/09\/SOFT-_ASIA-37-300x200.png 300w, https:\/\/softasia.jp\/blog\/wp-content\/uploads\/2025\/09\/SOFT-_ASIA-37.png 640w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p><strong>&#8216;TypeError: unsupported operand type(s)&#8217;<\/strong><\/p>\n<p><span style=\"font-weight: 400;\">\u65e5\u4ed8\u3068\u6587\u5b57\u5217\u3092\u76f4\u63a5\u8db3\u305d\u3046\u3068\u3059\u308b\u3068\u30a8\u30e9\u30fc\u306b\u306a\u308a\u307e\u3059\u3002<span style=\"text-decoration: underline;\">datetime\u578b\u3068str\u578b\u306f\u4e92\u63db\u6027\u304c\u306a\u3044\u305f\u3081\u3001strptime\u3067\u5909\u63db\u3057\u3066\u304b\u3089\u64cd\u4f5c\u3057\u307e\u3057\u3087\u3046<\/span>\u3002<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><strong>&#8216;ValueError: time data does not match format&#8217;<\/strong><\/p>\n<p><span style=\"font-weight: 400;\">strptime\u306e\u30d5\u30a9\u30fc\u30de\u30c3\u30c8\u304c\u6587\u5b57\u5217\u3068\u4e00\u81f4\u3057\u3066\u3044\u306a\u3044\u3068\u767a\u751f\u3057\u307e\u3059\u3002<span style=\"text-decoration: underline;\">\u30d5\u30a9\u30fc\u30de\u30c3\u30c8\u6307\u5b9a\u5b50\uff08\u4f8b:`%Y-%m-%d`\uff09\u304c\u6b63\u3057\u3044\u304b\u78ba\u8a8d\u3057\u307e\u3057\u3087\u3046<\/span>\u3002<\/span><\/p>\n<p>&nbsp;<\/p>\n<h2><span id=\"i-4\"><span style=\"font-weight: 400;\">\u6a5f\u68b0\u5b66\u7fd2\u3068\u306e\u95a2\u9023\u6027<\/span><\/span><\/h2>\n<p><img loading=\"lazy\" class=\"size-medium wp-image-2580 aligncenter\" src=\"https:\/\/softasia.jp\/blog\/wp-content\/uploads\/2025\/09\/SOFT-_ASIA-38-300x200.png\" alt=\"\" width=\"300\" height=\"200\" srcset=\"https:\/\/softasia.jp\/blog\/wp-content\/uploads\/2025\/09\/SOFT-_ASIA-38-300x200.png 300w, https:\/\/softasia.jp\/blog\/wp-content\/uploads\/2025\/09\/SOFT-_ASIA-38.png 640w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400;\">\u6a5f\u68b0\u5b66\u7fd2\u3067\u306f\u3001\u6642\u7cfb\u5217\u30c7\u30fc\u30bf\u306e\u524d\u51e6\u7406\u306bdatetime\u30e2\u30b8\u30e5\u30fc\u30eb\u304c\u983b\u7e41\u306b\u4f7f\u308f\u308c\u307e\u3059\u3002<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u4f8b\uff1a<\/span><\/p>\n<ul>\n<li><strong> \u30bb\u30f3\u30b5\u30fc\u30c7\u30fc\u30bf\u306e\u30bf\u30a4\u30e0\u30b9\u30bf\u30f3\u30d7\u51e6\u7406<\/strong><\/li>\n<li><span style=\"font-weight: 400;\"><strong> \u6642\u9593\u5e2f\u306b\u3088\u308b\u7279\u5fb4\u91cf\u306e\u62bd\u51fa<\/strong>\uff08\u4f8b\uff1a\u671d\u30fb\u663c\u30fb\u591c\uff09<\/span><\/li>\n<li><span style=\"font-weight: 400;\">\u00a0<strong>\u4e88\u6e2c\u30e2\u30c7\u30eb\u306b\u304a\u3051\u308b\u5b63\u7bc0\u6027\u306e\u8003\u616e<\/strong><\/span><\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400; color: #0000ff;\">df[&#8216;hour&#8217;] = df[&#8216;timestamp&#8217;].dt.hour<\/span><\/p>\n<p><span style=\"font-weight: 400; color: #0000ff;\">df[&#8216;weekday&#8217;] = df[&#8216;timestamp&#8217;].dt.weekday<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400;\">\u3053\u306e\u3088\u3046\u306b\u3001datetime\u306f\u5358\u306a\u308b\u65e5\u4ed8\u64cd\u4f5c\u4ee5\u4e0a\u306b\u3001\u30c7\u30fc\u30bf\u306e\u610f\u5473\u3092\u5f15\u304d\u51fa\u3059\u91cd\u8981\u306a\u30c4\u30fc\u30eb\u3067\u3059\u3002<\/span><\/p>\n<p>&nbsp;<\/p>\n<h2><span id=\"i-5\"><span style=\"font-weight: 400;\">\u307e\u3068\u3081<\/span><\/span><\/h2>\n<p><span style=\"font-weight: 400;\">Python\u306edatetime\u30e2\u30b8\u30e5\u30fc\u30eb\u306f\u3001\u521d\u5fc3\u8005\u3067\u3082\u6271\u3044\u3084\u3059\u304f\u3001\u5b9f\u52d9\u3067\u3082\u975e\u5e38\u306b\u5f79\u7acb\u3064\u6a5f\u80fd\u304c\u8a70\u307e\u3063\u3066\u3044\u307e\u3059\u3002\u65e5\u4ed8\u3084\u6642\u523b\u306e\u53d6\u5f97\u3001\u5909\u63db\u3001\u8a08\u7b97\u3001\u305d\u3057\u3066\u5fdc\u7528\u307e\u3067\u3001\u5e45\u5e83\u3044\u5834\u9762\u3067\u6d3b\u8e8d\u3057\u307e\u3059\u3002<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400;\">\u6a5f\u68b0\u5b66\u7fd2\u3084\u30c7\u30fc\u30bf\u5206\u6790\u3092\u5fd7\u3059\u65b9\u306f\u3082\u3061\u308d\u3093\u3001\u65e5\u5e38\u7684\u306a\u30b9\u30af\u30ea\u30d7\u30c8\u4f5c\u6210\u3067\u3082\u5fc5\u9808\u306e\u77e5\u8b58\u3067\u3059\u3002\u307e\u305a\u306f\u57fa\u672c\u64cd\u4f5c\u304b\u3089\u59cb\u3081\u3066\u3001\u5c11\u3057\u305a\u3064\u5fdc\u7528\u529b\u3092\u9ad8\u3081\u3066\u3044\u304d\u307e\u3057\u3087\u3046\uff01<\/span><\/p>\n<p>&nbsp;<\/p>\n<p>\u307e\u305f\u3001\u300c\u81ea\u793e\u30b7\u30b9\u30c6\u30e0\u306b\u65e5\u4ed8\u51e6\u7406\u3092\u7d44\u307f\u8fbc\u307f\u305f\u3044\u300d\u300c\u30c7\u30fc\u30bf\u5206\u6790\u3092\u52b9\u7387\u5316\u3057\u305f\u3044\u300d\u3068\u3044\u3063\u305f \u958b\u767a\u306e\u3054\u76f8\u8ac7 \u304c\u3042\u308c\u3070\u3001\u305c\u3072<a href=\"https:\/\/softasia.jp\/#contact\"><em><strong><span style=\"color: #0000ff;\">3ink<\/span><\/strong><\/em><\/a> \u307e\u3067\u304a\u554f\u3044\u5408\u308f\u305b\u304f\u3060\u3055\u3044\u3002\u5b9f\u52d9\u306b\u5373\u3057\u305f\u6700\u9069\u306a\u30bd\u30ea\u30e5\u30fc\u30b7\u30e7\u30f3\u3092\u3054\u63d0\u6848\u3044\u305f\u3057\u307e\u3059\u3002<br style=\"font-weight: 400;\" \/><br style=\"font-weight: 400;\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp; Python\u3067\u958b\u767a\u3084\u5206\u6790\u3092\u3057\u3066\u3044\u308b\u3068\u3001\u5fc5\u305a\u767b\u5834\u3059\u308b\u306e\u304c\u300c\u65e5\u4ed8\u300d\u3068\u300c\u6642\u523b\u300d\u306e\u6271\u3044\u3067\u3059\u3002\u30ed\u30b0\u306e\u8a18\u9332\u3001\u30d5\u30a1\u30a4\u30eb\u540d\u306b\u30bf\u30a4\u30e0\u30b9\u30bf\u30f3\u30d7\u3092\u4ed8\u3051\u308b\u3001\u30c7\u30fc\u30bf\u5206\u6790\u3067\u65e5\u4ed8\u3092\u57fa\u6e96\u306b\u30b0\u30eb\u30fc\u30d4\u30f3\u30b0\u3059\u308b\u3001\u306a\u3069\u6d3b\u7528\u30b7\u30fc\u30f3\u306f\u7121\u6570\u306b\u3042\u308a\u307e\u3059\u3002 [&hellip;]<\/p>\n","protected":false},"author":9,"featured_media":2585,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_mi_skip_tracking":false},"categories":[4,1,9],"tags":[],"jetpack_featured_media_url":"https:\/\/softasia.jp\/blog\/wp-content\/uploads\/2025\/09\/\u540d\u79f0\u672a\u8a2d\u5b9a\u306e\u30c7\u30b6\u30a4\u30f3.png","_links":{"self":[{"href":"https:\/\/softasia.jp\/blog\/wp-json\/wp\/v2\/posts\/2530"}],"collection":[{"href":"https:\/\/softasia.jp\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/softasia.jp\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/softasia.jp\/blog\/wp-json\/wp\/v2\/users\/9"}],"replies":[{"embeddable":true,"href":"https:\/\/softasia.jp\/blog\/wp-json\/wp\/v2\/comments?post=2530"}],"version-history":[{"count":27,"href":"https:\/\/softasia.jp\/blog\/wp-json\/wp\/v2\/posts\/2530\/revisions"}],"predecessor-version":[{"id":2642,"href":"https:\/\/softasia.jp\/blog\/wp-json\/wp\/v2\/posts\/2530\/revisions\/2642"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/softasia.jp\/blog\/wp-json\/wp\/v2\/media\/2585"}],"wp:attachment":[{"href":"https:\/\/softasia.jp\/blog\/wp-json\/wp\/v2\/media?parent=2530"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/softasia.jp\/blog\/wp-json\/wp\/v2\/categories?post=2530"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/softasia.jp\/blog\/wp-json\/wp\/v2\/tags?post=2530"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}