{"id":21810,"date":"2023-06-26T22:49:51","date_gmt":"2023-06-26T13:49:51","guid":{"rendered":"http:\/\/www.code-magagine.com\/?p=21810"},"modified":"2023-06-27T21:14:30","modified_gmt":"2023-06-27T12:14:30","slug":"%e3%80%90python%e3%80%91%e3%83%a2%e3%82%b8%e3%83%a5%e3%83%bc%e3%83%ab%e3%80%81%e3%83%91%e3%83%83%e3%82%b1%e3%83%bc%e3%82%b8%e3%80%81%e3%83%a9%e3%82%a4%e3%83%96%e3%83%a9%e3%83%aa","status":"publish","type":"post","link":"http:\/\/www.code-magagine.com\/?p=21810","title":{"rendered":"\u3010Python\u3011\u30e2\u30b8\u30e5\u30fc\u30eb\u3001\u81ea\u4f5c\u30e2\u30b8\u30e5\u30fc\u30eb\u3001\u30d1\u30c3\u30b1\u30fc\u30b8\u3001\u30e9\u30a4\u30d6\u30e9\u30ea"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">\u30e2\u30b8\u30e5\u30fc\u30eb(module)\u3068\u306f\uff1f<\/h2>\n\n\n\n<p>\u8907\u6570\u30d5\u30a1\u30a4\u30eb\u306b\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u5206\u3051\u308b\u969b\u306b\u4f7f\u3048\u308b\u6a5f\u80fd\u3067\u3059\u3002<\/p>\n\n\n\n<p>1\u3064\u306e\u30d5\u30a1\u30a4\u30eb\u30921\u3064\u306e\u30e2\u30b8\u30e5\u30fc\u30eb\u3068\u3057\u3066\u4f7f\u3048\u3066\u3001\u5225\u30d5\u30a1\u30a4\u30eb\u3067\u5b9a\u7fa9\u3055\u308c\u3066\u3044\u308b\u95a2\u6570\u3092\u547c\u3073\u51fa\u3059\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u69cb\u6587<\/h3>\n\n\n\n<h4 class=\"wp-block-heading\">\u30e2\u30b8\u30e5\u30fc\u30eb\u3092\u53d6\u308a\u8fbc\u3080<\/h4>\n\n\n\n<pre class=\"wp-block-preformatted\">import (\u30e2\u30b8\u30e5\u30fc\u30eb\u540d)\nimport (\u30e2\u30b8\u30e5\u30fc\u30eb\u540d) as \u5225\u540d <\/pre>\n\n\n\n<p>\u30b3\u30fc\u30c9\u5185\u3067\u77ed\u304f\u66f8\u3051\u308b\u3088\u3046\u306b\u30e2\u30b8\u30e5\u30fc\u30eb\u540d\u306e\u7565\u79f0\u3092\u5225\u540d\u3067\u8a18\u8ff0\u3059\u308b\u3053\u3068\u304c\u591a\u3044\u3067\u3059\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">\u53d6\u308a\u8fbc\u3093\u3060\u30e2\u30b8\u30e5\u30fc\u30eb\u3092\u4f7f\u3046\u3002\uff08\u30af\u30e9\u30b9\u3001\u95a2\u6570\u3001\u5909\u6570\u306e\u547c\u3073\u51fa\u3057\u65b9\uff09<\/h4>\n\n\n\n<pre class=\"wp-block-preformatted\">\u30e2\u30b8\u30e5\u30fc\u30eb\u540d.\u30af\u30e9\u30b9\u540d\n\u30e2\u30b8\u30e5\u30fc\u30eb\u540d.\u95a2\u6570\u540d()\n\u30e2\u30b8\u30e5\u30fc\u30eb\u540d.\u5909\u6570\u540d<\/pre>\n\n\n\n<h5 class=\"wp-block-heading\">\u30e2\u30b8\u30e5\u30fc\u30eb\u306e\u968e\u5c64\u304c\u6df1\u3044\u3068\u304d<\/h5>\n\n\n\n<p>\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u968e\u5c64\u306e\u8a18\u8ff0\u3060\u3051\u306f\u3057\u3066\u3057\u307e\u3046\u306e\u304c\u30d9\u30bf\u30fc\u3067\u3059\u3002\uff08\u30bd\u30fc\u30b9\u5185\u306b\u968e\u5c64\u304c\u81f3\u308b\u6240\u306b\u8a18\u8ff0\u3057\u3066\u3042\u308b\u3068\u8aad\u307f\u3065\u3089\u3044\u3067\u3059\u3057\u306d\u3002\uff09<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>from xxx.yyy import zzz\nzzz.\u95a2\u6570\u540d()<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">import\u3057\u306a\u304f\u3066\u3082\u4f7f\u3048\u308b\u7d44\u307f\u8fbc\u307f\u95a2\u6570<\/h3>\n\n\n\n<p>Python\u3067\u306f\u3001\u300cprint()\u300d\u3084\u3001\u300cstr()\u300d\u7b49\u3001import\u3057\u306a\u304f\u3066\u3082\u4f7f\u3046\u3053\u3068\u304c\u3067\u304d\u305f\u95a2\u6570\u304c\u3042\u3063\u305f\u304b\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u305d\u3046\u3057\u305f\u95a2\u6570\u3092<span style=\"color: #ff0000;\"><strong>\u300c\u7d44\u307f\u8fbc\u307f\u95a2\u6570\u300d<\/strong><\/span>\u3068\u547c\u3073\u307e\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u6a19\u6e96\u30e2\u30b8\u30e5\u30fc\u30eb<\/h3>\n\n\n\n<p>\u307e\u305f\u3001\u30e2\u30b8\u30e5\u30fc\u30eb\u306f\u3044\u3061\u3044\u3061\u81ea\u4f5c\u3057\u306a\u304f\u3066\u3082\u3001\u6700\u521d\u304b\u3089\u3044\u304f\u3064\u304b\u306e<span style=\"color: #ff0000;\"><strong>\u300c\u6a19\u6e96\u30e2\u30b8\u30e5\u30fc\u30eb\u300d<\/strong><\/span>\u3068\u3044\u3046\u5f62\u3067\u30e2\u30b8\u30e5\u30fc\u30eb\u304c\u63d0\u4f9b\u3055\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u4e0b\u8a18\u306ePython\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u306b\u3066\u3001Python\u306e\u6a19\u6e96\u30e2\u30b8\u30e5\u30fc\u30eb\u3092\u691c\u7d22\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<p><a href=\"https:\/\/docs.python.jp\/3\/py-modindex.html\">https:\/\/docs.python.jp\/3\/py-modindex.html<\/a><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u69d8\u3005\u306a\u30e2\u30b8\u30e5\u30fc\u30eb<\/h3>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><th>\u30e2\u30b8\u30e5\u30fc\u30eb\u540d<\/th><th>\u8aac\u660e<\/th><\/tr><tr><td>re<\/td><td>\u6b63\u898f\u8868\u73fe\u3092\u6271\u3048\u308b\u3002<\/td><\/tr><tr><td>random<\/td><td>\u4e71\u6570\u3092\u751f\u6210\u3067\u304d\u308b\u3002<\/td><\/tr><tr><td>datetime<\/td><td>\u65e5\u6642\u51e6\u7406\u95a2\u3059\u308b\u30e2\u30b8\u30e5\u30fc\u30eb<\/td><\/tr><tr><td>json<\/td><td>JSON\u5f62\u5f0f\u306e\u30c7\u30fc\u30bf\u3092\u8aad\u307f\u53d6\u308b\u3002<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">\u81ea\u4f5c\u30e2\u30b8\u30e5\u30fc\u30eb<\/h2>\n\n\n\n<p>\u30e2\u30b8\u30e5\u30fc\u30eb\u3092\u81ea\u4f5c\u3059\u308b\u5834\u5408\u306f\u5fc5\u9808\u306e\u6982\u5ff5\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">test2.py(\u4eca\u56de\u4f5c\u6210\u3057\u305f\u3044\u30e2\u30b8\u30e5\u30fc\u30eb)<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>def func2():\r\n    print(\"func2\u3067\u3059\u3002\")\r\n\r\ndef func3():\r\n    print(\"func3\u3067\u3059\u3002\")\r\nfunc3()<\/code><\/pre>\n\n\n\n<p>\u3053\u308c\u3092\u666e\u901a\u306b\u547c\u3073\u51fa\u3059\u3068\u95a2\u6570func3\u3060\u3051\u304c\u5b9f\u884c\u3055\u308c\u307e\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">test.py(\u30e2\u30b8\u30e5\u30fc\u30eb\u3092\u547c\u3073\u51fa\u3059\u5074)<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code># \u3053\u308c\u3092\u547c\u3073\u51fa\u3059\u3068test2\u30e2\u30b8\u30e5\u30fc\u30eb\u306e\u5185\u5bb9\u304c\u5168\u3066\u5b9f\u884c\u3055\u308c\u308b\u3002\r\nimport test2\r\n\r\ntest2.func2()\r<\/code><\/pre>\n\n\n\n<p>\u3053\u308c\u3092\u5b9f\u884c\u3059\u308b\u3068\u5b9f\u884c\u7d50\u679c\u306f\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" loading=\"lazy\" width=\"112\" height=\"45\" src=\"http:\/\/www.code-magagine.com\/wp-content\/uploads\/2023\/06\/image-47.png\" alt=\"\" class=\"wp-image-21866\"\/><\/figure>\n\n\n\n<p>\u7406\u7531\u3068\u3057\u3066\u306f\u30e2\u30b8\u30e5\u30fc\u30eb\u3092\u30a4\u30f3\u30dd\u30fc\u30c8\u3057\u305f\u30bf\u30a4\u30df\u30f3\u30b0\u3067\u30e2\u30b8\u30e5\u30fc\u30eb\u306e\u5185\u5bb9\u304c\u3059\u3079\u3066\u5b9f\u884c\u3055\u308c\u308b\u4ed5\u69d8\u306b\u306a\u3063\u3066\u3044\u308b\u305f\u3081\u3067\u3059\u3002<\/p>\n\n\n\n<p>\u306a\u306e\u3067\u4f5c\u6210\u3057\u305f\u30e2\u30b8\u30e5\u30fc\u30eb\u5074\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u3057\u3066\u3042\u3052\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>def func2():\r\n    print(\"func2\u3067\u3059\u3002\")\r\n\r\n\r\ndef func3():\r\n    print(\"func3\u3067\u3059\u3002\")\r\n\r\n\r\nif __name__ == \"__main__\":\r\n    func3()\r<\/code><\/pre>\n\n\n\n<p><strong>\u3053\u3046\u3059\u308b\u3053\u3068\u3067\u4ed6\u306ePython\u30d5\u30a1\u30a4\u30eb\u304b\u3089\u3053\u306e\u30d5\u30a1\u30a4\u30eb\u3092\u30a4\u30f3\u30dd\u30fc\u30c8\u3057\u305f\u3068\u304d\u306bif\u6587\u306e\u5916\u306e\u30b3\u30fc\u30c9\u304c\u81ea\u52d5\u3067\u5b9f\u884c\u3055\u308c\u3066\u3057\u307e\u3046\u3053\u3068\u3092\u9632\u6b62\u3059\u308b<\/strong>\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u30d1\u30c3\u30b1\u30fc\u30b8\u3068\u306f\uff1f<\/h2>\n\n\n\n<p>Python\u3067\u3001<span style=\"color: #ff0000;\"><strong>\u8907\u6570\u306e\u30e2\u30b8\u30e5\u30fc\u30eb\u3092\u7d44\u307f\u5408\u308f\u305b\u305f\u3082\u306e<\/strong><\/span>\u3092\u3001\u30d1\u30c3\u30b1\u30fc\u30b8\u3068\u547c\u3073\u307e\u3059\u3002\u30e2\u30b8\u30e5\u30fc\u30eb\uff08\u30d5\u30a1\u30a4\u30eb\uff09\u3092\u307e\u3068\u3081\u305f\u30d5\u30a9\u30eb\u30c0\u306e\u3088\u3046\u306a\u30a4\u30e1\u30fc\u30b8\uff08\u3068\u3044\u3046\u304b\u5b9f\u614b\uff09\u3067\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">PyPI<\/h2>\n\n\n\n<p>Python\u306e\u30d1\u30c3\u30b1\u30fc\u30b8\u304c\u591a\u6570\u767b\u9332\u3055\u308c\u3066\u3044\u308b<span style=\"color: #ff0000;\"><strong>\u30d1\u30c3\u30b1\u30fc\u30b8\u30ea\u30dd\u30b8\u30c8\u30ea<\/strong><\/span>\u3067\u3059\u3002<\/p>\n\n\n\n<p>\u4e0b\u8a18\u306e\u30b5\u30a4\u30c8\u3067\u3001PyPI\u306b\u3069\u3093\u306a\u30d1\u30c3\u30b1\u30fc\u30b8\u304c\u3042\u308b\u304b\u691c\u7d22\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<p><a href=\"https:\/\/pypi.org\/\">https:\/\/pypi.org\/<\/a><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u30d1\u30c3\u30b1\u30fc\u30b8\u7ba1\u7406\u30c4\u30fc\u30eb\u300cpip\uff08\u30d4\u30c3\u30d7\u307e\u305f\u306f\u3001\u30d1\u30a4\u30d7\u3068\u8aad\u307f\u307e\u3059\u3002\uff09\u300d<\/h3>\n\n\n\n<p>\u300cPyPI\u300d\u306b\u767b\u9332\u3055\u308c\u3066\u3044\u308b\u30d1\u30c3\u30b1\u30fc\u30b8\u306f\u3001\u30d1\u30c3\u30b1\u30fc\u30b8\u7ba1\u7406\u30c4\u30fc\u30eb\u306e\u300cpip\u300d\u3092\u4f7f\u3046\u3053\u3068\u3067\u3001\u624b\u8efd\u306b\u4f7f\u3046\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u306a\u304a\u3001Python\u306e\u30d0\u30fc\u30b8\u30e7\u30f33.4\u4ee5\u4e0a\u3067\u3042\u308c\u3070\u30a4\u30f3\u30b9\u30c8\u30fc\u30e9\u30fc\u306b\u30c7\u30d5\u30a9\u30eb\u30c8\u3067\u5165\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">pip\u3067\u30d1\u30c3\u30b1\u30fc\u30b8\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b\u3002<\/h4>\n\n\n\n<pre class=\"wp-block-preformatted\">pip install (\u30d1\u30c3\u30b1\u30fc\u30b8\u540d)<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u69d8\u3005\u306a\u30d1\u30c3\u30b1\u30fc\u30b8<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><th>\u30d1\u30c3\u30b1\u30fc\u30b8\u540d<\/th><th>\u8aac\u660e<\/th><\/tr><tr><td>qrcode<\/td><td>QR\u30b3\u30fc\u30c9\u3092\u751f\u6210\u3059\u308b\u3002<\/td><\/tr><tr><td>pycrypto<\/td><td>\u6697\u53f7\u5316\u30e9\u30a4\u30d6\u30e9\u30ea<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">\u30e9\u30a4\u30d6\u30e9\u30ea<\/h2>\n\n\n\n<p>\u8907\u6570\u306e\u30d1\u30c3\u30b1\u30fc\u30b8\u3092\u3072\u3068\u307e\u3068\u3081\u306b\u3057\u305f\u7269\u306e\u3053\u3068\u3067\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u30e2\u30b8\u30e5\u30fc\u30eb(module)\u3068\u306f\uff1f \u8907\u6570\u30d5\u30a1\u30a4\u30eb\u306b\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u5206\u3051\u308b\u969b\u306b\u4f7f\u3048\u308b\u6a5f\u80fd\u3067\u3059\u3002 1\u3064\u306e\u30d5\u30a1\u30a4\u30eb\u30921\u3064\u306e\u30e2\u30b8\u30e5\u30fc\u30eb\u3068\u3057\u3066\u4f7f\u3048\u3066\u3001\u5225\u30d5\u30a1\u30a4\u30eb\u3067\u5b9a\u7fa9\u3055\u308c\u3066\u3044\u308b\u95a2\u6570\u3092\u547c\u3073\u51fa\u3059\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002 \u69cb\u6587 \u30e2\u30b8\u30e5\u30fc\u30eb\u3092\u53d6\u308a\u8fbc\u3080  [&hellip;]","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[47],"tags":[],"_links":{"self":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts\/21810"}],"collection":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=21810"}],"version-history":[{"count":8,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts\/21810\/revisions"}],"predecessor-version":[{"id":21867,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts\/21810\/revisions\/21867"}],"wp:attachment":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=21810"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=21810"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=21810"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}