{"id":129,"date":"2019-11-15T16:04:10","date_gmt":"2019-11-15T07:04:10","guid":{"rendered":"http:\/\/aiacademy.jp\/media\/?p=129"},"modified":"2024-08-08T16:34:07","modified_gmt":"2024-08-08T07:34:07","slug":"%e3%80%90%e5%88%9d%e5%bf%83%e8%80%85%e5%90%91%e3%81%91%e3%80%91%e3%83%a2%e3%82%b8%e3%83%a5%e3%83%bc%e3%83%ab%e3%83%bb%e3%83%91%e3%83%83%e3%82%b1%e3%83%bc%e3%82%b8%e3%81%a8%e3%81%af%e4%bd%95%e3%81%8b","status":"publish","type":"post","link":"https:\/\/aiacademy.jp\/media\/?p=129","title":{"rendered":"\u3010\u521d\u5fc3\u8005\u5411\u3051\u3011\u30e2\u30b8\u30e5\u30fc\u30eb\u30fb\u30d1\u30c3\u30b1\u30fc\u30b8\u3068\u306f\u4f55\u304b\uff1f"},"content":{"rendered":"<div id=\"sgb-css-id-1\">\n<div class=\"wp-block-buttons is-layout-flex wp-block-buttons-is-layout-flex\">\n<div class=\"wp-block-button has-custom-font-size is-style-fill has-medium-font-size\"><a class=\"wp-block-button__link has-vivid-green-cyan-background-color has-background wp-element-button\" href=\"https:\/\/lin.ee\/3E4GzWk\" rel=\"nofollow noopener\" target=\"_blank\">LINE\u53cb\u3060\u3061\u767b\u9332 \u25b6 Python\u30b3\u30fc\u30b9 \u25b6 \u53d7\u8b1b\u5272\u5f15\u30af\u30fc\u30dd\u30f3 \u7121\u6599\u52d5\u753b<\/a><\/div>\n<\/div>\n<\/div>\n\n<div class=\"toc\">    <div id=\"toc_container\" class=\"sgb-toc--no-bullets js-smooth-scroll\" data-dialog-title=\"Table of Contents\">\n      <p class=\"toc_title\">\u76ee\u6b21 <\/p>\n      <ul class=\"toc_list\">  <li class=\"first\">    <a href=\"#i-0\">\u306f\u3058\u3081\u306b<\/a>  <\/li>  <li>    <a href=\"#i-1\">\u30e9\u30a4\u30d6\u30e9\u30ea<\/a>  <\/li>  <li>    <a href=\"#i-2\">\u30e2\u30b8\u30e5\u30fc\u30eb\u3068\u30d1\u30c3\u30b1\u30fc\u30b8<\/a>  <\/li>  <li>    <a href=\"#i-3\">\u30e2\u30b8\u30e5\u30fc\u30eb\u306e\u30a4\u30f3\u30dd\u30fc\u30c8<\/a>  <\/li>  <li>    <a href=\"#i-4\">\u72ec\u81ea\u3067\u4f5c\u6210\u3057\u305f\u30e2\u30b8\u30e5\u30fc\u30eb\u3092\u30a4\u30f3\u30dd\u30fc\u30c8\u3059\u308b<\/a>  <\/li>  <li>    <a href=\"#i-5\">from\u3068import<\/a>  <\/li>  <li>    <a href=\"#i-6\">\u5225\u540d\u3067\u306e\u30e2\u30b8\u30e5\u30fc\u30eb\u306e\u30a4\u30f3\u30dd\u30fc\u30c8<\/a>  <\/li>  <li>    <a href=\"#i-7\">\u5fc5\u8981\u306a\u3082\u306e\u3060\u3051\u3092\u30a4\u30f3\u30dd\u30fc\u30c8\u3059\u308b<\/a>  <\/li>  <li>    <a href=\"#i-8\">\u30e9\u30a4\u30d6\u30e9\u30ea\u30fb\u30e2\u30b8\u30e5\u30fc\u30eb\u306e\u5834\u6240\u3092\u8abf\u3079\u308b<\/a>  <\/li>  <li>    <a href=\"#i-9\">\u304a\u307f\u304f\u3058\u30a2\u30d7\u30ea\u3092\u5b9f\u884c\u3057\u3066\u307f\u308b\u3002<\/a>  <\/li>  <li class=\"last\">    <a href=\"#i-10\">\u307e\u3068\u3081<\/a>  <\/li><\/ul>\n      \n    <\/div><\/div><div class=\"toc\"><p><\/p>\n<\/div><h2 id=\"i-0\">\u306f\u3058\u3081\u306b<\/h2>\n<p>\u3053\u306e\u7ae0\u3067\u306f\u3001\u304a\u597d\u304d\u306a\u30c6\u30ad\u30b9\u30c8\u30a8\u30c7\u30a3\u30bf\u3068\u30bf\u30fc\u30df\u30ca\u30eb(\u30b3\u30de\u30f3\u30c9\u30d7\u30ed\u30f3\u30d7\u30c8)\u3092\u5143\u306b\u3001\u81ea\u4f5c\u3057\u305f\u30e2\u30b8\u30e5\u30fc\u30eb\u3092\u8aad\u307f\u8fbc\u307f\u5229\u7528\u3057\u3066\u3044\u304d\u307e\u3059\u3002<br>\u305d\u306e\u305f\u3081\u3001Jupyter Notebook\u3084Google Colab\u306e\u5834\u5408\u3001\u3053\u306e\u7ae0\u306b\u66f8\u304b\u308c\u3066\u3044\u308b\u30d7\u30ed\u30b0\u30e9\u30e0\u3060\u3068\u52d5\u4f5c\u3057\u306a\u3044\u305f\u3081\u3001\u6b21\u306e\u6d41\u308c\u3067\u8a66\u3057\u3066\u898b\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p>\u307e\u305f\u3001\u4e0b\u8a18\u30ea\u30f3\u30af\u304b\u3089Colab\u4e0a\u3067\u52d5\u4f5c\u3059\u308b\u65b9\u6cd5\u3082\u3042\u3052\u3066\u3044\u307e\u3059\u306e\u3067\u78ba\u8a8d\u3057\u3066\u307f\u3066\u304f\u3060\u3055\u3044\u3002<br><a href=\"https:\/\/youtu.be\/gJS1krnczxE\" rel=\"nofollow noopener\" target=\"_blank\">YouTube\u52d5\u753b \/ Colab\u306b\u3066\u52d5\u4f5c\u3055\u305b\u308b<\/a><\/p>\n<p>1) \u304a\u624b\u5143\u306ePC\u3067fortune.py\u3092\u4f5c\u6210\u3002<br>\u6b21\u306b\u3001Colab\u306e\u5de6\u30e1\u30cb\u30e5\u30fc(&gt;\u3092\u62bc\u3057\u307e\u3059)\u304b\u3089\u3001\u76ee\u6b21\u3001\u30b3\u30fc\u30c9\u30b9\u30cb\u30da\u30c3\u30c8\u3001\u30d5\u30a1\u30a4\u30eb\u306e3\u3064\u304c\u8868\u793a\u3055\u308c\u3001\u305d\u306e\u4e2d\u306e\u30d5\u30a1\u30a4\u30eb\u30bf\u30d6\u3092\u9078\u629e\u3059\u308b\u3002<\/p>\n<p>2) 1\u3067\u958b\u3044\u305f\u30bf\u30d6\u304b\u3089\u3001\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u3092\u62bc\u3059\u3068\u3001\u624b\u5143\u306ePC\u3067\u4f5c\u6210\u3057\u305ffortune.py\u3092\u9078\u629e\u51fa\u6765\u308b\u306e\u3067\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u3059\u308b\u3002<\/p>\n<pre><code># fortune.py\ndef get_fortune():\n    import random # randam\u3067\u306f\u306a\u304f\u3001random\u306a\u306e\u3067\u6ce8\u610f\u3067\u3059\n    results = ['\u5927\u5409', '\u5409', '\u5c0f\u5409', '\u51f6', '\u5927\u51f6', '\u672b\u5409']\n    return random.choice(results)\n<\/code><\/pre>\n<p>3) \u305d\u306e\u5f8cColab\u5074\u3067\u6b21\u306e\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u5b9f\u884c\u3002<\/p>\n<pre><code>import fortune\nresult = fortune.get_fortune()\nprint(\"\u4eca\u65e5\u306e\u904b\u52e2\u306f\uff0e\uff0e\uff0e\", result)\n<\/code><\/pre>\n<h2 id=\"i-1\">\u30e9\u30a4\u30d6\u30e9\u30ea<\/h2>\n<p><strong>\u30e9\u30a4\u30d6\u30e9\u30ea\u3068\u306f\u3001\u3042\u308b\u7a0b\u5ea6\u307e\u3068\u307e\u3063\u305f\u6c4e\u7528\u6027\u306e\u9ad8\u3044\u51e6\u7406\uff08\u95a2\u6570\u30fb\u30af\u30e9\u30b9\u30fb\u305d\u306e\u4ed6\uff09\u3092\u4ed6\u306e\u30d7\u30ed\u30b0\u30e9\u30e0\u304b\u3089\u8aad\u307f\u8fbc\u3080\u3053\u3068\u3067\u3001\u4f7f\u3046\u3053\u3068\u304c\u51fa\u6765\u308b\u3088\u3046\u306b\u3057\u305f\u30d5\u30a1\u30a4\u30eb\u3067\u3059\u3002<\/strong><br>Python\u5185\u3067\u306f\u57fa\u672c\u7684\u306bimport\u3067\u304d\u308b\u3082\u306e\u3092\u30e9\u30a4\u30d6\u30e9\u30ea\u3068\u547c\u3093\u3060\u308a\u3057\u307e\u3059\u3002<br>\u306a\u304a\u3001\u30e9\u30a4\u30d6\u30e9\u30ea\u306f\u4e00\u822c\u7684\u306a\u547c\u3073\u540d\u3067\u3042\u308a\u3001Python\u3067\u306f\u3001\u57fa\u672c\u7684\u306b\u30e9\u30a4\u30d6\u30e9\u30ea\u3068\u3044\u3046\u8868\u8a18\u304c\u3042\u3063\u305f\u3089\u3001\u4e0b\u8a18\u3067\u8aac\u660e\u3059\u308b\u30e2\u30b8\u30e5\u30fc\u30eb\u306e\u3053\u3068\u3060\u3068\u601d\u3063\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<h2 id=\"i-2\">\u30e2\u30b8\u30e5\u30fc\u30eb\u3068\u30d1\u30c3\u30b1\u30fc\u30b8<\/h2>\n<p><strong><em>\u30e2\u30b8\u30e5\u30fc\u30eb\u306fPython\u306e\u30b3\u30fc\u30c9\u3092\u307e\u3068\u3081\u305f\u30d5\u30a1\u30a4\u30eb\u3067\u3042\u308a\u3001\u4ed6\u306e\u30d7\u30ed\u30b0\u30e9\u30e0\u304b\u3089\u518d\u5229\u7528\u3067\u304d\u308b\u3088\u3046\u306b\u3057\u305f\u30d5\u30a1\u30a4\u30eb\u306e\u3053\u3068\u3092\u300c\u30e2\u30b8\u30e5\u30fc\u30eb\uff63\u3068\u8a00\u3044\u307e\u3059\u3002<\/em><\/strong><br>\u305d\u308c\u5358\u4f53\u3067\u306f\u52d5\u4f5c\u3057\u307e\u305b\u3093\u304c\u3001import\u3059\u308b\u3053\u3068\u3067\u30e2\u30b8\u30e5\u30fc\u30eb\u304c\u4f7f\u3048\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<br><strong><em>\u30d1\u30c3\u30b1\u30fc\u30b8\u3068\u306f__init__.py\u3068\u8907\u6570\u306e\u30e2\u30b8\u30e5\u30fc\u30eb\u304c\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306b\u96c6\u307e\u3063\u305f\u3082\u306e\u3067\u3059\u3002<\/em><\/strong><br>__init__.py\u306f\u30d1\u30c3\u30b1\u30fc\u30b8\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306b\u7f6e\u304b\u308c\u3001\u305d\u306e\u30d1\u30c3\u30b1\u30fc\u30b8\u3092\u30a4\u30f3\u30dd\u30fc\u30c8\u3057\u305f\u969b\u306b\u5b9f\u884c\u3055\u308c\u307e\u3059\u3002<\/p>\n<h2 id=\"i-3\">\u30e2\u30b8\u30e5\u30fc\u30eb\u306e\u30a4\u30f3\u30dd\u30fc\u30c8<\/h2>\n<p>import\u6587\u306e\u5358\u7d14\u306a\u4f7f\u3044\u65b9\u306f\u6b21\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<br><strong>import \u8aad\u307f\u8fbc\u307f\u305f\u3044\u30e2\u30b8\u30e5\u30fc\u30eb<\/strong><br>\u8aad\u307f\u8fbc\u307f\u305f\u3044\u30e2\u30b8\u30e5\u30fc\u30eb\u306e\u90e8\u5206\u306f\u3001\u4ed6\u306ePython\u30d5\u30a1\u30a4\u30eb\u306e\u30d5\u30a1\u30a4\u30eb\u540d\u304b\u3089\u62e1\u5f35\u5b50\u306e.py\u3092\u53d6\u308a\u9664\u3044\u305f\u3082\u306e\u3067\u3059\u3002<br>\u4f8b\u3048\u3070\u3001sys\u30e2\u30b8\u30e5\u30fc\u30eb\u3092\u8aad\u307f\u8fbc\u307f\u305f\u3044\u6642\u306f\u6b21\u306e\u3088\u3046\u306b\u3057\u307e\u3059\u3002<br>(sys\u30e2\u30b8\u30e5\u30fc\u30eb\u306f\u3001Python\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u305f\u6bb5\u968e\u3067\u5229\u7528\u3067\u304d\u308b\u30e2\u30b8\u30e5\u30fc\u30eb\u306e1\u3064\u3067\u3059\u3002\u3053\u308c\u3092<strong>\u6a19\u6e96\u30e2\u30b8\u30e5\u30fc\u30eb<\/strong>\u3068\u547c\u3073\u3001\u4ed6\u306b\u3082os\u30e2\u30b8\u30e5\u30fc\u30eb\u306a\u3069\u69d8\u3005\u3042\u308a\u307e\u3059\u3002)<\/p>\n<pre><code>import sys\n<\/code><\/pre>\n<p>\u8907\u6570\u306e\u30e2\u30b8\u30e5\u30fc\u30eb\u3092\u30a4\u30f3\u30dd\u30fc\u30c8\u3059\u308b\u5834\u5408\u3001\u300c,\u300d\u3067\u30e2\u30b8\u30e5\u30fc\u30eb\u540d\u3092\u533a\u5207\u3063\u3066\u30a4\u30f3\u30dd\u30fc\u30c8\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre><code>import sys, os\n<\/code><\/pre>\n<p>\u4f8b\u3048\u3070math\u30e2\u30b8\u30e5\u30fc\u30eb\u306ecos\u95a2\u6570\u3092\u5229\u7528\u3057\u305f\u3044\u5834\u5408\u306f<strong>\u30e2\u30b8\u30e5\u30fc\u30eb\u540d.\u95a2\u6570\u540d(\u5f15\u6570\uff09<\/strong>\u3067\u5229\u7528\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre><code>import math\nmath.cos(1) # 0.5403023058681398\n<\/code><\/pre>\n<h2 id=\"i-4\">\u72ec\u81ea\u3067\u4f5c\u6210\u3057\u305f\u30e2\u30b8\u30e5\u30fc\u30eb\u3092\u30a4\u30f3\u30dd\u30fc\u30c8\u3059\u308b<\/h2>\n<p>\u4eca\u56de\u306f\u904b\u52e2\u30d7\u30ed\u30b0\u30e9\u30e0(\u5360\u3044\u30e2\u30b8\u30e5\u30fc\u30eb)\u3092\u4f5c\u308a\u307e\u3059\u3002<br>\u307e\u305amain\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<br>\uff08\u30d5\u30a1\u30a4\u30eb\u540d\u306f\u81ea\u7531\u3067\u3059\u304c\u3053\u3053\u3067\u306fmain.py\u3068\u3057\u307e\u3059\u3002\uff09<\/p>\n<p>\u201c`python:main.py<br>import fortune<\/p>\n<p>result = fortune.get_fortune()<br>print(\u201c\u4eca\u65e5\u306e\u904b\u52e2\u306f\u2026 \u201c, result)<\/p>\n<p>&lt;pre&gt;&lt;code&gt;&lt;br \/&gt;\u3067\u306f\u6b21\u306bfortune\u30e2\u30b8\u30e5\u30fc\u30eb\u3092\u4f5c\u3063\u3066\u3044\u304d\u307e\u3059\u3002<br>\u4e0b\u8a18\u30d7\u30ed\u30b0\u30e9\u30e0\u3092**fortune.py**\u3068\u3044\u3046\u30d5\u30a1\u30a4\u30eb\u540d\u3067\u4e0a\u306e\u4f5c\u6210\u3057\u305fmain\u30d7\u30ed\u30b0\u30e9\u30e0(main.py)\u3068\u540c\u3058\u5834\u6240\u306b\u4fdd\u5b58\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p>\u201c`python:fortune.py<br>def get_fortune():<br>import random # randam\u3067\u306f\u306a\u304f\u3001random\u306a\u306e\u3067\u6ce8\u610f\u3067\u3059<br>results = [\u2018\u5927\u5409\u2019, \u2018\u5409\u2019, \u2018\u5c0f\u5409\u2019, \u2018\u51f6\u2019, \u2018\u5927\u51f6\u2019, \u2018\u672b\u5409\u2019]<br>return random.choice(results)<\/p>\n<p>\u305d\u308c\u3067\u306f\u3001main.py\u3068fortune.py\u3092\u540c\u3058\u30d5\u30a9\u30eb\u30c0\u306b\u4fdd\u5b58\u3057\u3066\u3042\u308b\u3068\u601d\u3044\u307e\u3059\u306e\u3067\u3001\u4f5c\u6210\u3057\u305fmain.py\u3092\u5b9f\u884c\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002<br>\u5b9f\u884c\u3059\u308b\u306b\u306f\u3001Mac\u3092\u304a\u4f7f\u3044\u306e\u65b9\u306f\u3001\u30bf\u30fc\u30df\u30ca\u30eb\u3001Windows\u306e\u65b9\u306f\u30b3\u30de\u30f3\u30c9\u30d7\u30ed\u30f3\u30d7\u30c8\u304b\u3089\u3001\u4fdd\u5b58\u3055\u308c\u305fmain.py\u3092\u5b9f\u884c\u3057\u307e\u3059\u3002<\/p>\n<pre><code class=\"shell:\">python main.py\n<\/code><\/pre>\n<p><strong><em>\u4e0a\u8a18\u3092\u5b9f\u884c\u3059\u308b\u969b\u306b\u3001\u305d\u306e\u307e\u307e\u30bf\u30fc\u30df\u30ca\u30eb\u3092\u8d77\u52d5\u3057\u3066\u4e0a\u8a18\u306e\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3057\u305f\u5834\u5408\u306b\u3001(null): can\u2019t open file \u2018main.py\u2019: [Errno 2] No such file or directory\u3068\u3044\u3046\u30a8\u30e9\u30fc\u304c\u3067\u308b\u5834\u5408\u304c\u3042\u308a\u307e\u3059\u3002<\/em><\/strong><br>\u3053\u308c\u306f\u3001main.py\u3068\u3044\u3046\u30d5\u30a1\u30a4\u30eb\u304c\u4eca\u3044\u308b\u968e\u5c64\u306b\u5b58\u5728\u3057\u306a\u3044\u305f\u3081\u3067\u3059\u3002<\/p>\n<p>\u5b9f\u884c\u3059\u308b\u5ea6\u306b\u3001\u51fa\u529b\u7d50\u679c\u304c\u5909\u308f\u308c\u3070\u554f\u984c\u306a\u304f\u52d5\u4f5c\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<h2 id=\"i-5\">from\u3068import<\/h2>\n<p><strong><em>from \u30d5\u30a1\u30a4\u30eb\u540d(\u30e2\u30b8\u30e5\u30fc\u30eb\u540d) import *<\/em><\/strong>\u3067\u30d5\u30a1\u30a4\u30eb\u540d\u306e\u6307\u5b9a\u306a\u3057\u306b\u547c\u3073\u51fa\u3057\u304c\u53ef\u80fd\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre><code class=\"plaintext:\">from \u30e2\u30b8\u30e5\u30fc\u30eb\u540d import *\n<\/code><\/pre>\n<p>\u30e2\u30b8\u30e5\u30fc\u30eb\u306e\u95a2\u6570\u306a\u3069\u3092\u5229\u7528\u3059\u308b\u969b\u306b\u3001\u30e2\u30b8\u30e5\u30fc\u30eb\u540d.\u306e\u8a18\u8ff0\u3092\u7701\u7565\u3057\u3066\u95a2\u6570\u540d\u3060\u3051\u3067\u4f7f\u7528\u3057\u305f\u3044\u5834\u5408\u306f\u4ee5\u4e0b\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre><code class=\"shell:\">from \u30e2\u30b8\u30e5\u30fc\u30eb\u540d import \u95a2\u6570\u540d, \u95a2\u6570\u540d, ...\n<\/code><\/pre>\n<p>\u4e0a\u8a18\u306e\u69cb\u6587\u3092\u5143\u306b\u6b21\u306e\u3088\u3046\u306b\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u66f8\u304f\u3053\u3068\u304c\u51fa\u6765\u307e\u3059\u3002<\/p>\n<pre><code>from math import cos, sin, tan\ncos(1)\n<\/code><\/pre>\n<p>\u5148\u307b\u3069\u3001fortune.py\u3067random.choice(results)\u3068\u8a18\u8ff0\u3057\u307e\u3057\u305f\u304c\u3001<br>fortune.py\u306ffrom\u3092\u4f7f\u3044\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u66f8\u304d\u63db\u3048\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre><code>def get_fortune():\n    from random import choice\n    results = ['\u5927\u5409', '\u5409', '\u5c0f\u5409', '\u51f6', '\u5927\u51f6', '\u672b\u5409']\n    return choice(results)\n<\/code><\/pre>\n<p>\u307e\u305f\u3001\u540d\u524d\u3092\u6307\u5b9a\u305b\u305a\u306b\u30e2\u30b8\u30e5\u30fc\u30eb\u5185\u306e\u3059\u3079\u3066\u306e\u30e1\u30f3\u30d0(\u95a2\u6570\u3001\u5b9a\u6570\u3001\u30af\u30e9\u30b9\u306a\u3069\u306e\u3053\u3068)\u3092\u30a4\u30f3\u30dd\u30fc\u30c8\u3059\u308b\u5834\u5408\u306f\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u6307\u5b9a\u3057\u307e\u3059\u3002<\/p>\n<pre><code># from \u30e2\u30b8\u30e5\u30fc\u30eb\u540d import *\nfrom math import *\ncos(1)\nsin(1)\n<\/code><\/pre>\n<p>fortune.py\u3067random\u3092\u30b5\u30f3\u30d7\u30eb\u3067import\u3057\u3066\u3044\u308b\u306e\u306f\u95a2\u6570\u5185\u3067\u3059\u304c\u3001<br>\u95a2\u6570\u5916\u3067\u3082\u30a4\u30f3\u30dd\u30fc\u30c8\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre><code>from random import *\n\ndef get_fortune():\n    results = ['\u5927\u5409', '\u5409', '\u5c0f\u5409', '\u51f6', '\u5927\u51f6', '\u672b\u5409']\n    return choice(results)\n\nprint(get_fortune())\nsin(1)\n<\/code><\/pre>\n<h2 id=\"i-6\">\u5225\u540d\u3067\u306e\u30e2\u30b8\u30e5\u30fc\u30eb\u306e\u30a4\u30f3\u30dd\u30fc\u30c8<\/h2>\n<pre><code># main.py\nimport fortune\n\nresult = fortune.get_fortune()\nprint(\"\u4eca\u65e5\u306e\u904b\u52e2\u306f... \", result)\n<\/code><\/pre>\n<p>import fortune\u3068\u8a18\u8ff0\u3057\u3066\u3044\u307e\u3057\u305f\u304c\u3001as\u3092\u7528\u3044\u308b\u3053\u3068\u3067\u3001\u5225\u540d\u3092\u3064\u3051\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<br>\u4ee5\u4e0b\u304c\u5225\u540d\u3092\u3064\u3051\u305f\u30b5\u30f3\u30d7\u30eb\u3067\u3059\u3002<\/p>\n<pre><code>import fortune as ft\n\nresult = ft.get_fortune()\nprint(\"\u4eca\u65e5\u306e\u904b\u52e2\u306f... \", result)\n<\/code><\/pre>\n<p>\u5225\u540d\u3092\u3064\u3051\u305f\u3053\u3068\u3067ft.get_fortune()\u3068\u547c\u3073\u51fa\u3059\u3053\u3068\u304c\u51fa\u6765\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3057\u305f\u3002<\/p>\n<h2 id=\"i-7\">\u5fc5\u8981\u306a\u3082\u306e\u3060\u3051\u3092\u30a4\u30f3\u30dd\u30fc\u30c8\u3059\u308b<\/h2>\n<p>*\u3067\u5168\u3066\u30a4\u30f3\u30dd\u30fc\u30c8\u3057\u307e\u3057\u305f\u304c\u3001\u5fc5\u8981\u306a\u90e8\u54c1\u3060\u3051\u3082\u30a4\u30f3\u30dd\u30fc\u30c8\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre><code>from fortune import get_fortune\n\nresult = get_fortune()\nprint(\"\u4eca\u65e5\u306e\u904b\u52e2\u306f... \", result)\n<\/code><\/pre>\n<p>\u307e\u305f\u5225\u540d\u3092\u3064\u3051\u3001\u304b\u3064get_fortune\u3060\u3051\u30a4\u30f3\u30dd\u30fc\u30c8\u3059\u308b\u30b5\u30f3\u30d7\u30eb\u3067\u3059\u3002<\/p>\n<pre><code>from fortune import get_fortune as gf\n\nresult = gf()\nprint(\"\u4eca\u65e5\u306e\u904b\u52e2\u306f... \", result)\n<\/code><\/pre>\n<h2 id=\"i-8\">\u30e9\u30a4\u30d6\u30e9\u30ea\u30fb\u30e2\u30b8\u30e5\u30fc\u30eb\u306e\u5834\u6240\u3092\u8abf\u3079\u308b<\/h2>\n<p><strong>\u30e9\u30a4\u30d6\u30e9\u30ea\u306e\u5834\u6240\u306f\u3001\u30e2\u30b8\u30e5\u30fc\u30eb\u306e <strong>file<\/strong> \u30a2\u30c8\u30ea\u30d3\u30e5\u30fc\u30c8\u304b <strong>path<\/strong> \u30a2\u30c8\u30ea\u30d3\u30e5\u30fc\u30c8\u3067\u8abf\u3079\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/strong><br>\u4f8b\u3048\u3070\u6b21\u306e\u3088\u3046\u306b\u3059\u308b\u3053\u3068\u3067\u8abf\u3079\u3089\u308c\u307e\u3059\u3002<\/p>\n<pre><code>import os\nprint( os.__file__ ) # \/Users\/aiacademy\/anaconda3\/lib\/python3.6\/os.py\n<\/code><\/pre>\n<h2 id=\"i-9\">\u304a\u307f\u304f\u3058\u30a2\u30d7\u30ea\u3092\u5b9f\u884c\u3057\u3066\u307f\u308b\u3002<\/h2>\n<p>Mac\u306e\u65b9\u306f\u3001\u30bf\u30fc\u30df\u30ca\u30eb\u3001Windows\u306e\u65b9\u306f\u30b3\u30de\u30f3\u30c9\u30d7\u30ed\u30f3\u30d7\u30c8\u3092\u8d77\u52d5\u3057\u3001\u5148\u307b\u3069\u4f5c\u6210\u3057\u305fmain.py\u3092\u6b21\u306emain.py\u304c\u3042\u308b\u30d5\u30a9\u30eb\u30c0\u306b\u79fb\u52d5\u3057\u3001\u5b9f\u884c\u3057\u3066\u898b\u307e\u3057\u3087\u3046\u3002<\/p>\n<pre><code class=\"shell\">python main.py\n<\/code><\/pre>\n<p>\u5b9f\u884c\u3059\u308b\u3068\u3001<\/p>\n<pre><code class=\"shell\">\u4eca\u65e5\u306e\u904b\u52e2\u306f... \u25cb\u25cb\u3067\u3059\u3002\n<\/code><\/pre>\n<p>\u3068\u3044\u3046\u3088\u3046\u306b\u3001\u25cb\u25cb\u306b\u306f\u3001\u30e9\u30f3\u30c0\u30e0\u3067\u5b9f\u884c\u6bce\u306b\u904b\u52e2\u306e\u7d50\u679c\u304c\u5909\u308f\u3063\u3066\u3044\u308b\u306e\u304c\u308f\u304b\u308b\u304b\u3068\u601d\u3044\u307e\u3059\u3002<br>\u3082\u3057\u3053\u306e\u7ae0\u3067\u304a\u307f\u304f\u3058\u30a2\u30d7\u30ea\u304c\u5b9f\u884c\u3067\u304d\u306a\u304b\u3063\u305f\u5834\u5408\u306f\u4e0b\u8a18\u30c6\u30ad\u30b9\u30c8\u3092\u3054\u53c2\u8003\u304f\u3060\u3055\u3044\u3002<br><a href=\"?id=193\">\u30b3\u30de\u30f3\u30c9\u30d7\u30ed\u30f3\u30d7\u30c8\u3067\u52d5\u4f5c\u3059\u308b\u304a\u307f\u304f\u3058\u30a2\u30d7\u30ea\u3092\u4f5c\u3063\u3066\u307f\u3088\u3046\uff01<\/a><\/p>\n<h2 id=\"i-10\">\u307e\u3068\u3081<\/h2>\n<p>\u3053\u306e\u7ae0\u3067\u306f\u30e2\u30b8\u30e5\u30fc\u30eb\u306b\u95a2\u3057\u3066\u306e\u57fa\u790e\u3092\u5b66\u3073\u307e\u3057\u305f\u3002<br>\u69d8\u3005\u306a\u8aad\u307f\u8fbc\u307f\u65b9(import)\u304c\u3042\u308a\u307e\u3059\u306e\u3067\u3001\u3069\u308c\u3082\u4f7f\u3044\u3053\u306a\u305b\u308b\u3088\u3046\u306b\u3057\u307e\u3057\u3087\u3046\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"aiacademy.jp\/bootcamp\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"341\" src=\"https:\/\/aiacademy.jp\/media\/wp-content\/uploads\/2021\/12\/bootcamp_ad_72ppi-1024x341.png\" alt=\"\" class=\"wp-image-691\" srcset=\"https:\/\/aiacademy.jp\/media\/wp-content\/uploads\/2021\/12\/bootcamp_ad_72ppi-1024x341.png 1024w, https:\/\/aiacademy.jp\/media\/wp-content\/uploads\/2021\/12\/bootcamp_ad_72ppi-300x100.png 300w, https:\/\/aiacademy.jp\/media\/wp-content\/uploads\/2021\/12\/bootcamp_ad_72ppi-768x256.png 768w, https:\/\/aiacademy.jp\/media\/wp-content\/uploads\/2021\/12\/bootcamp_ad_72ppi-940x313.png 940w, https:\/\/aiacademy.jp\/media\/wp-content\/uploads\/2021\/12\/bootcamp_ad_72ppi.png 1200w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\"><\/a><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>\u76ee\u6b21 \u306f\u3058\u3081\u306b \u30e9\u30a4\u30d6\u30e9\u30ea \u30e2\u30b8\u30e5\u30fc\u30eb\u3068\u30d1\u30c3\u30b1\u30fc\u30b8 \u30e2\u30b8\u30e5\u30fc\u30eb\u306e\u30a4\u30f3\u30dd\u30fc\u30c8 \u72ec\u81ea\u3067\u4f5c\u6210\u3057\u305f\u30e2\u30b8\u30e5\u30fc\u30eb\u3092\u30a4\u30f3\u30dd\u30fc\u30c8\u3059\u308b from\u3068import \u5225\u540d\u3067\u306e\u30e2\u30b8\u30e5\u30fc\u30eb\u306e\u30a4\u30f3\u30dd\u30fc\u30c8 \u5fc5\u8981\u306a\u3082\u306e\u3060\u3051\u3092\u30a4\u30f3\u30dd\u30fc\u30c8\u3059\u308b \u30e9\u30a4\u30d6\u30e9\u30ea\u30fb\u30e2 &#8230; <\/p>\n","protected":false},"author":1,"featured_media":484,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[85,98,90,97],"tags":[],"class_list":{"0":"post-129","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-python","8":"category-98","9":"category-90","10":"category-97"},"_links":{"self":[{"href":"https:\/\/aiacademy.jp\/media\/index.php?rest_route=\/wp\/v2\/posts\/129","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/aiacademy.jp\/media\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/aiacademy.jp\/media\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/aiacademy.jp\/media\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/aiacademy.jp\/media\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=129"}],"version-history":[{"count":5,"href":"https:\/\/aiacademy.jp\/media\/index.php?rest_route=\/wp\/v2\/posts\/129\/revisions"}],"predecessor-version":[{"id":4882,"href":"https:\/\/aiacademy.jp\/media\/index.php?rest_route=\/wp\/v2\/posts\/129\/revisions\/4882"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/aiacademy.jp\/media\/index.php?rest_route=\/wp\/v2\/media\/484"}],"wp:attachment":[{"href":"https:\/\/aiacademy.jp\/media\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=129"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/aiacademy.jp\/media\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=129"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/aiacademy.jp\/media\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=129"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}