{"id":1596,"date":"2020-06-06T23:05:53","date_gmt":"2020-06-06T14:05:53","guid":{"rendered":"https:\/\/obenkyolab.com\/?p=1596"},"modified":"2021-06-05T23:53:06","modified_gmt":"2021-06-05T14:53:06","slug":"python-format%e3%81%ae%e5%9f%ba%e6%9c%ac%e7%9a%84%e3%81%aa%e4%bd%bf%e3%81%84%e6%96%b9","status":"publish","type":"post","link":"https:\/\/obenkyolab.com\/?p=1596","title":{"rendered":"Python format\u306e\u57fa\u672c\u7684\u306a\u4f7f\u3044\u65b9"},"content":{"rendered":"\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_80 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/obenkyolab.com\/?p=1596\/#%E7%9B%AE%E7%9A%84\" >\u76ee\u7684<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/obenkyolab.com\/?p=1596\/#%E6%96%87%E5%AD%97%E5%88%97%E6%95%B4%E5%BD%A2\" >\u6587\u5b57\u5217\u6574\u5f62<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/obenkyolab.com\/?p=1596\/#%E5%9E%8B%E6%8C%87%E5%AE%9A\" >\u578b\u6307\u5b9a<\/a><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E7%9B%AE%E7%9A%84\"><\/span>\u76ee\u7684<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>python3\u7cfb\u306e\u6587\u5b57\u5217\u64cd\u4f5c\u306e\u30e1\u30bd\u30c3\u30c9\u3067\u3042\u308bformat\u306e\u57fa\u672c\u7684\u306a\u4f7f\u3044\u65b9\u306b\u3064\u3044\u3066\u52c9\u5f37\u3059\u308b\u3002<\/p>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E6%96%87%E5%AD%97%E5%88%97%E6%95%B4%E5%BD%A2\"><\/span>\u6587\u5b57\u5217\u6574\u5f62<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>format\u306e\u5f15\u6570\u306b\u6587\u5b57\u5217\u7b49\uff08int\u3084float\u306a\u3069\u3082\u5bfe\u5fdc\uff09\u3092\u79c1\u3001\u6587\u5b57\u5217\u5185\u306b{}\u3092\u57cb\u3081\u8fbc\u3080\u3068\u3001\u6e21\u3057\u305f\u9806\u5e8f\u3067\u6587\u5b57\u5217\u3092\u8fd4\u3059\u3002<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\n&gt;&gt;&gt; a = &#039;I&#039;\n&gt;&gt;&gt; b = &#039;am&#039;\n&gt;&gt;&gt; c = &#039;a cat.&#039;\n&gt;&gt;&gt; print(&#039;{} {} {}&#039;.format(a,b,c))\nI am a cat.\n<\/pre><\/div>\n\n\n<p>\u57cb\u3081\u8fbc\u3080\u9806\u5e8f\u3092\u5236\u5fa1\u3057\u305f\u3044\u5834\u5408\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u5f15\u6570\u306e\u9806\u5e8f\u3092\u8a18\u5165\u3059\u308c\u3070\u3067\u304d\u308b\u3002<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\n&gt;&gt;&gt; print(&#039;{1} {2} {0}&#039;.format(c,a,b))\nI am a cat.\n<\/pre><\/div>\n\n\n<p>\u8f9e\u66f8\u578b\u3092\u4f7f\u7528\u3057\u3066\u6574\u5f62\u3059\u308b\u3053\u3068\u3082\u3067\u304d\u308b\u3002\u6587\u5b57\u5217\u5185\u3067\u30ad\u30fc\u30d0\u30ea\u30e5\u30fc\u3092\u6307\u5b9a\u3059\u308c\u3070\u5236\u5fa1\u3067\u304d\u308b\u30020\u306f\u4e00\u3064\u76ee\u306e\u5f15\u6570\u3068\u3044\u3046\u610f\u5473\u3067\u3001\u4eee\u306b\u5f15\u6570\u304c\u8907\u6570\u3042\u308b\u5834\u5408\u306f1,2&#8230;\u3068\u6307\u5b9a\u3057\u3066\u540c\u69d8\u306b\u547c\u3073\u51fa\u3059\u3053\u3068\u304c\u3067\u304d\u308b\u3002<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\nd = {&#039;I&#039;:&#039;\u543e\u8f29&#039;,&#039;am&#039;:&#039;\u306f&#039;,&#039;a cat&#039;:&#039;\u732b\u3067\u3042\u308b&#039;}\nprint(&#039;{0&#x5B;I]} {0&#x5B;am]} {0&#x5B;a cat]}&#039;.format(d))\n<\/pre><\/div>\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E5%9E%8B%E6%8C%87%E5%AE%9A\"><\/span>\u578b\u6307\u5b9a<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>\u6587\u5b57\u5217\u5185\u306b\u57cb\u3081\u8fbc\u3080\u969b\u306e\u578b\u6307\u5b9a\u3082\u53ef\u80fd\u3067\u3042\u308b\u3002<\/p>\n\n\n\n<p>d : 10\u9032\u6570int<br>f :  10\u9032\u6570float<br>x : 16\u9032\u6570<br>o : 8\u9032\u6570<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\n&gt;&gt;&gt;print(&#039;{e:d},{e:f},{e:x},{e:o}&#039;.format(e=10))\n10,10.000000,a,12\n<\/pre><\/div>\n\n\n<p><\/p>\n\n\n\n<p><strong><span style=\"text-decoration: underline;\">Python\u3092\u4e00\u304b\u3089\u5b66\u3076\u306e\u306b\u304a\u3059\u3059\u3081\u306e\u672c\u306f\u30b3\u30c1\u30e9<\/span><\/strong><\/p>\n\n\n\n<iframe style=\"width:120px;height:240px;\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\" frameborder=\"0\" src=\"https:\/\/rcm-fe.amazon-adsystem.com\/e\/cm?ref=qf_sp_asin_til&#038;t=sebone0f-22&#038;m=amazon&#038;o=9&#038;p=8&#038;l=as1&#038;IS2=1&#038;detail=1&#038;asins=4873117380&#038;linkId=665846163826975f4858844e1483e9e7&#038;bc1=000000&amp;lt1=_blank&#038;fc1=333333&#038;lc1=0066c0&#038;bg1=ffffff&#038;f=ifr\">\n    <\/iframe>\n","protected":false},"excerpt":{"rendered":"<p>\u76ee\u7684 python3\u7cfb\u306e\u6587\u5b57\u5217\u64cd\u4f5c\u306e\u30e1\u30bd\u30c3\u30c9\u3067\u3042\u308bformat\u306e\u57fa\u672c&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":1218,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_locale":"ja","_original_post":"https:\/\/obenkyolab.com\/?p=1596","footnotes":""},"categories":[7],"tags":[],"class_list":["post-1596","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-python","ja"],"_links":{"self":[{"href":"https:\/\/obenkyolab.com\/index.php?rest_route=\/wp\/v2\/posts\/1596","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/obenkyolab.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/obenkyolab.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/obenkyolab.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/obenkyolab.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1596"}],"version-history":[{"count":7,"href":"https:\/\/obenkyolab.com\/index.php?rest_route=\/wp\/v2\/posts\/1596\/revisions"}],"predecessor-version":[{"id":2907,"href":"https:\/\/obenkyolab.com\/index.php?rest_route=\/wp\/v2\/posts\/1596\/revisions\/2907"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/obenkyolab.com\/index.php?rest_route=\/wp\/v2\/media\/1218"}],"wp:attachment":[{"href":"https:\/\/obenkyolab.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1596"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/obenkyolab.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1596"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/obenkyolab.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1596"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}