{"id":294,"date":"2026-05-03T16:19:32","date_gmt":"2026-05-03T07:19:32","guid":{"rendered":"https:\/\/smartlife123.tech\/?p=294"},"modified":"2026-05-03T16:29:24","modified_gmt":"2026-05-03T07:29:24","slug":"%e3%80%90python%e3%80%91%e6%b0%97%e3%81%ab%e5%85%a5%e3%81%a3%e3%81%9f%e8%8b%b1%e6%96%87%e3%82%92%e3%81%95%e3%81%a3%e3%81%a8%e5%af%be%e8%a8%b3%e6%95%99%e6%9d%90%e3%81%ab%e3%81%a7%e3%81%8d%e3%82%8b","status":"publish","type":"post","link":"https:\/\/smartlife123.tech\/?p=294","title":{"rendered":"\u3010Python\u3011\u6c17\u306b\u5165\u3063\u305f\u82f1\u6587\u3092\u3055\u3063\u3068\u5bfe\u8a33&amp;\u6559\u6750\u306b\u3067\u304d\u308bCUI\u30a2\u30d7\u30ea\u3092\u4f5c\u3063\u3066\u307f\u305f"},"content":{"rendered":"\n<h3 class=\"wp-block-heading\">\u25a0\u524d\u7f6e\u304d<\/h3>\n\n\n\n<p>Python\u306e\u52c9\u5f37\u304c\u3066\u3089\u4f5c\u308a\u307e\u3057\u305f<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u3067\u304d\u308b\u3053\u3068\uff1a1\u6587\u6bce\u306b\u5bfe\u8a33\u4f5c\u6210\u3057\u30c6\u30b9\u30c8\u3067\u304d\u308b\u3002\u9593\u9055\u3048\u305f\u3068\u3053\u308d\u3092\u4f55\u5ea6\u3067\u3082\u5fa9\u7fd2\u53ef\u80fd\u3002<\/li>\n<\/ul>\n\n\n\n<p>\u6975\u3081\u3066\u30b7\u30f3\u30d7\u30eb\u3001\u4fdd\u5b58\u3059\u3089\u3067\u304d\u307e\u305b\u3093<\/p>\n\n\n\n<p><\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><br>\u25a0\u5fc5\u8981\u306a\u3082\u306e<\/h3>\n\n\n\n<p>Deepl API key\uff08\u7121\u6599\uff09<\/p>\n\n\n\n<p><\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><br>\u25a0\u30b3\u30fc\u30c9<\/h3>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\nimport urllib.request\nimport urllib.parse\nimport json\nimport re\n\n# ==========================================\n# \u8a2d\u5b9a\n# ==========================================\nAPI_KEY = &quot;YOUR_DEEPL_API_KEY&quot; # \u3053\u3053\u306bAPI key\u3044\u308c\u308b\nDEEPL_URL = &quot;https:\/\/api-free.deepl.com\/v2\/translate&quot;\n\n# ==========================================\n# \u95a2\u6570\n# ==========================================\ndef translate_text(text):\n    data = urllib.parse.urlencode({\n        &#039;text&#039;: text,\n        &#039;target_lang&#039;: &#039;JA&#039;\n    }).encode(&#039;utf-8&#039;)\n    \n    headers = {\n        &#039;Authorization&#039;: f&#039;DeepL-Auth-Key {API_KEY}&#039;,\n        &#039;Content-Type&#039;: &#039;application\/x-www-form-urlencoded&#039;\n    }\n    \n    req = urllib.request.Request(DEEPL_URL, data=data, headers=headers)\n    try:\n        with urllib.request.urlopen(req) as response:\n            res_json = json.loads(response.read().decode(&#039;utf-8&#039;))\n            return res_json&#x5B;&#039;translations&#039;]&#x5B;0]&#x5B;&#039;text&#039;]\n    except Exception as e:\n        return f&quot;\u3010\u7ffb\u8a33\u30a8\u30e9\u30fc\u3011: {e}&quot;\n\ndef split_sentences(text):\n    text = text.replace(&#039;\\n&#039;, &#039; &#039;)\n    text = re.sub(r&#039;\\s+&#039;, &#039; &#039;, text).strip()\n    sentences = re.split(r&#039;(?&lt;=&#x5B;.!?])\\s+&#039;, text)\n    return &#x5B;s for s in sentences if s]\n\ndef learning_session(sentences):\n    mistakes = &#x5B;]\n    total_sentences = len(sentences)\n    \n    for i, sentence in enumerate(sentences):\n        print(&quot;\\n&quot; + &quot;=&quot;*40)\n        print(f&quot;\u3010 {i + 1} \/ {total_sentences} \u6587\u76ee \u3011&quot;)\n        print(&quot;-&quot; * 40)\n        print(sentence)\n        \n        input(&quot;\\n(Enter\u3092\u62bc\u3057\u3066\u65e5\u672c\u8a9e\u8a33\u3092\u8868\u793a...)&quot;)\n        \n        ja_text = translate_text(sentence)\n        print(&quot;\\n\u3010\u65e5\u672c\u8a9e\u8a33\u3011&quot;)\n        print(ja_text)\n        \n        while True:\n            ans = input(&quot;\\n\u5408\u3063\u3066\u3044\u307e\u3057\u305f\u304b\uff1f (y\/n): &quot;).strip().lower()\n            \n            # y\/n \u306e\u5224\u5b9a\u3092\u30ac\u30d0\u30ac\u30d0\u306b\u3059\u308b\uff08\u5168\u89d2\u3084\u7a7a\u767d\u6df7\u5165\u5bfe\u7b56\uff09\n            if &#039;y&#039; in ans or &#039;\uff59&#039; in ans:\n                break\n            elif &#039;n&#039; in ans or &#039;\uff4e&#039; in ans:\n                mistakes.append(sentence)\n                if i + 1 &lt; total_sentences:\n                    input(&quot;(Enter\u3092\u62bc\u3057\u3066\u6b21\u306e\u82f1\u6587\u3078...)&quot;)\n                break\n            elif ans == &quot;&quot;:\n                continue # \u7a7a\u30a8\u30f3\u30bf\u30fc\u9023\u6253\u306f\u7121\u8996\n            else:\n                print(&quot;\u203b y \u307e\u305f\u306f n \u3092\u5165\u529b\u3057\u3066\u304f\u3060\u3055\u3044\u3002&quot;)\n                \n    return mistakes\n\n# ==========================================\n# \u30e1\u30a4\u30f3\u51e6\u7406\n# ==========================================\ndef main():\n    mistake_list = &#x5B;]\n    \n    while True:\n        print(&quot;\\n\\n&quot; + &quot;*&quot;*40)\n        print(&quot; \u30e1\u30cb\u30e5\u30fc&quot;)\n        print(&quot;*&quot;*40)\n        print(&quot;1: \u82f1\u6587\u3092\u5165\u529b\u3057\u3066\u5b66\u7fd2\u3092\u958b\u59cb\u3059\u308b&quot;)\n        print(f&quot;2: \u9593\u9055\u3048\u30ea\u30b9\u30c8\u3092\u5b66\u7fd2\u3059\u308b (\u73fe\u5728 {len(mistake_list)} \u6587)&quot;)\n        print(&quot;3: \u30a2\u30d7\u30ea\u3092\u7d42\u4e86\u3059\u308b&quot;)\n        \n        choice = input(&quot;\\n\u756a\u53f7\u3092\u9078\u629e\u3057\u3066\u304f\u3060\u3055\u3044 (1-3): &quot;).strip()\n        \n        if choice == &#039;1&#039;:\n            print(&quot;\\n\u82f1\u6587\u3092\u30da\u30fc\u30b9\u30c8\uff08\u5165\u529b\uff09\u3057\u3066\u304f\u3060\u3055\u3044\u3002&quot;)\n            print(&quot;\u203b \u3059\u3079\u3066\u30da\u30fc\u30b9\u30c8\u3057\u7d42\u308f\u3063\u305f\u3089\u3001\u65b0\u3057\u3044\u884c\u306b\u300cEND\u300d\u3068\u5165\u529b\u3057\u3066Enter\u3092\u62bc\u3057\u3066\u304f\u3060\u3055\u3044\u3002&quot;)\n            \n            lines = &#x5B;]\n            while True:\n                line = input()\n                # END \u3068\u5165\u529b\u3055\u308c\u305f\u3089\u8aad\u307f\u8fbc\u307f\u7d42\u4e86\n                if line.strip().upper() == &quot;END&quot;: \n                    break\n                lines.append(line)\n            \n            full_text = &quot; &quot;.join(lines)\n            if not full_text.strip():\n                print(&quot;\u82f1\u6587\u304c\u5165\u529b\u3055\u308c\u307e\u305b\u3093\u3067\u3057\u305f\u3002&quot;)\n                continue\n                \n            sentences = split_sentences(full_text)\n            print(f&quot;\\n&gt;&gt;&gt; \u82f1\u6587\u3092 {len(sentences)} \u6587\u306b\u5206\u5272\u3057\u307e\u3057\u305f\u3002\u5b66\u7fd2\u3092\u30b9\u30bf\u30fc\u30c8\u3057\u307e\u3059\uff01&quot;)\n            \n            new_mistakes = learning_session(sentences)\n            \n            for m in new_mistakes:\n                if m not in mistake_list:\n                    mistake_list.append(m)\n                    \n            print(&quot;\\n=== \u5168\u3066\u306e\u82f1\u6587\u306e\u5b66\u7fd2\u304c\u5b8c\u4e86\u3057\u307e\u3057\u305f\uff01 ===&quot;)\n            \n        elif choice == &#039;2&#039;:\n            if not mistake_list:\n                print(&quot;\\n\u203b \u9593\u9055\u3048\u30ea\u30b9\u30c8\u306f\u7a7a\u3067\u3059\u3002\u307e\u305a\u306f\u300c1\u300d\u3067\u5b66\u7fd2\u3057\u3066\u304f\u3060\u3055\u3044\u3002&quot;)\n                continue\n                \n            print(f&quot;\\n&gt;&gt;&gt; \u9593\u9055\u3048\u30ea\u30b9\u30c8\uff08\u5168 {len(mistake_list)} \u6587\uff09\u306e\u5b66\u7fd2\u3092\u958b\u59cb\u3057\u307e\u3059\uff01&quot;)\n            remaining_mistakes = learning_session(mistake_list)\n            mistake_list = remaining_mistakes\n            print(&quot;\\n=== \u9593\u9055\u3048\u30ea\u30b9\u30c8\u306e\u5b66\u7fd2\u304c\u5b8c\u4e86\u3057\u307e\u3057\u305f\uff01 ===&quot;)\n            \n        elif choice == &#039;3&#039;:\n            print(&quot;\\n\u304a\u75b2\u308c\u69d8\u3067\u3057\u305f\uff01\u30a2\u30d7\u30ea\u3092\u7d42\u4e86\u3057\u307e\u3059\u3002&quot;)\n            break\n\nif __name__ == &quot;__main__&quot;:\n    main()\n<\/pre><\/div>\n\n\n<p><\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><br>\u25a0\u4f7f\u3063\u3066\u307f\u305f<\/h3>\n\n\n\n<p>BBC\u306e\u8a18\u4e8b\u3092\u62dd\u501f<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1080\" height=\"810\" src=\"https:\/\/smartlife123.tech\/wp-content\/uploads\/2026\/05\/1753-edited.png\" alt=\"\" class=\"wp-image-299\" srcset=\"https:\/\/smartlife123.tech\/wp-content\/uploads\/2026\/05\/1753-edited.png 1080w, https:\/\/smartlife123.tech\/wp-content\/uploads\/2026\/05\/1753-edited-300x225.png 300w, https:\/\/smartlife123.tech\/wp-content\/uploads\/2026\/05\/1753-edited-1024x768.png 1024w, https:\/\/smartlife123.tech\/wp-content\/uploads\/2026\/05\/1753-edited-768x576.png 768w\" sizes=\"auto, (max-width: 1080px) 100vw, 1080px\" \/><\/figure>\n\n\n\n<p><br>\u30a2\u30d7\u30ea\u3092\u8d77\u52d5<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1080\" height=\"809\" src=\"https:\/\/smartlife123.tech\/wp-content\/uploads\/2026\/05\/1754-edited-1.png\" alt=\"\" class=\"wp-image-298\" srcset=\"https:\/\/smartlife123.tech\/wp-content\/uploads\/2026\/05\/1754-edited-1.png 1080w, https:\/\/smartlife123.tech\/wp-content\/uploads\/2026\/05\/1754-edited-1-300x225.png 300w, https:\/\/smartlife123.tech\/wp-content\/uploads\/2026\/05\/1754-edited-1-1024x767.png 1024w, https:\/\/smartlife123.tech\/wp-content\/uploads\/2026\/05\/1754-edited-1-768x575.png 768w\" sizes=\"auto, (max-width: 1080px) 100vw, 1080px\" \/><\/figure>\n\n\n\n<p><br>\u30e2\u30fc\u30c9\u9078\u629e\u3057\u8cbc\u308a\u4ed8\u3051<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1079\" height=\"809\" src=\"https:\/\/smartlife123.tech\/wp-content\/uploads\/2026\/05\/1756-edited.png\" alt=\"\" class=\"wp-image-301\" srcset=\"https:\/\/smartlife123.tech\/wp-content\/uploads\/2026\/05\/1756-edited.png 1079w, https:\/\/smartlife123.tech\/wp-content\/uploads\/2026\/05\/1756-edited-300x225.png 300w, https:\/\/smartlife123.tech\/wp-content\/uploads\/2026\/05\/1756-edited-1024x768.png 1024w, https:\/\/smartlife123.tech\/wp-content\/uploads\/2026\/05\/1756-edited-768x576.png 768w\" sizes=\"auto, (max-width: 1079px) 100vw, 1079px\" \/><\/figure>\n\n\n\n<p><br>\u5b9f\u884c\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1080\" height=\"810\" src=\"https:\/\/smartlife123.tech\/wp-content\/uploads\/2026\/05\/1757-edited.png\" alt=\"\" class=\"wp-image-303\" srcset=\"https:\/\/smartlife123.tech\/wp-content\/uploads\/2026\/05\/1757-edited.png 1080w, https:\/\/smartlife123.tech\/wp-content\/uploads\/2026\/05\/1757-edited-300x225.png 300w, https:\/\/smartlife123.tech\/wp-content\/uploads\/2026\/05\/1757-edited-1024x768.png 1024w, https:\/\/smartlife123.tech\/wp-content\/uploads\/2026\/05\/1757-edited-768x576.png 768w\" sizes=\"auto, (max-width: 1080px) 100vw, 1080px\" \/><\/figure>\n\n\n\n<p><br>\u5fa9\u7fd2\u30e2\u30fc\u30c9<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1080\" height=\"1441\" src=\"https:\/\/smartlife123.tech\/wp-content\/uploads\/2026\/05\/1758-edited.png\" alt=\"\" class=\"wp-image-305\" srcset=\"https:\/\/smartlife123.tech\/wp-content\/uploads\/2026\/05\/1758-edited.png 1080w, https:\/\/smartlife123.tech\/wp-content\/uploads\/2026\/05\/1758-edited-225x300.png 225w, https:\/\/smartlife123.tech\/wp-content\/uploads\/2026\/05\/1758-edited-767x1024.png 767w, https:\/\/smartlife123.tech\/wp-content\/uploads\/2026\/05\/1758-edited-768x1025.png 768w\" sizes=\"auto, (max-width: 1080px) 100vw, 1080px\" \/><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>\u25a0\u524d\u7f6e\u304d Python\u306e\u52c9\u5f37\u304c\u3066\u3089\u4f5c\u308a\u307e\u3057\u305f \u6975\u3081\u3066\u30b7\u30f3\u30d7\u30eb\u3001\u4fdd\u5b58\u3059\u3089\u3067\u304d\u307e\u305b\u3093 \u25a0\u5fc5\u8981\u306a\u3082\u306e Deepl API key\uff08\u7121\u6599\uff09 \u25a0\u30b3\u30fc\u30c9 \u25a0\u4f7f\u3063\u3066\u307f\u305f BBC\u306e\u8a18\u4e8b\u3092\u62dd\u501f \u30a2\u30d7\u30ea\u3092\u8d77\u52d5 \u30e2\u30fc\u30c9\u9078\u629e\u3057\u8cbc\u308a\u4ed8\u3051 \u5b9f\u884c\u3002  [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":307,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[1],"tags":[],"class_list":["post-294","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-uncategorized"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/smartlife123.tech\/wp-content\/uploads\/2026\/05\/deepl-scaled-1.webp","jetpack_sharing_enabled":true,"jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/smartlife123.tech\/index.php?rest_route=\/wp\/v2\/posts\/294","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/smartlife123.tech\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/smartlife123.tech\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/smartlife123.tech\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/smartlife123.tech\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=294"}],"version-history":[{"count":1,"href":"https:\/\/smartlife123.tech\/index.php?rest_route=\/wp\/v2\/posts\/294\/revisions"}],"predecessor-version":[{"id":306,"href":"https:\/\/smartlife123.tech\/index.php?rest_route=\/wp\/v2\/posts\/294\/revisions\/306"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/smartlife123.tech\/index.php?rest_route=\/wp\/v2\/media\/307"}],"wp:attachment":[{"href":"https:\/\/smartlife123.tech\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=294"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/smartlife123.tech\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=294"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/smartlife123.tech\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=294"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}