{"id":8141,"date":"2019-09-15T14:19:38","date_gmt":"2019-09-15T05:19:38","guid":{"rendered":"http:\/\/www.gisdeveloper.co.kr\/?p=8141"},"modified":"2020-05-28T10:16:05","modified_gmt":"2020-05-28T01:16:05","slug":"python-%ec%95%8c%ed%8c%8c%eb%b2%b3%ec%9d%84-%ec%9d%b8%eb%8d%b1%ec%8a%a4%eb%a1%9c-%ea%b5%ac%ec%84%b1%ed%95%98%ea%b8%b0","status":"publish","type":"post","link":"http:\/\/www.gisdeveloper.co.kr\/?p=8141","title":{"rendered":"[Python] \uc54c\ud30c\ubcb3\uc744 \uc778\ub371\uc2a4\ub85c \uad6c\uc131\ud558\uae30"},"content":{"rendered":"<p>\uba3c\uc800 \ub2e4\uc74c\uacfc \uac19\uc740 \ubb38\uc7a5\uc774 \uc788\ub2e4\uace0 \ud558\uc790.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\">\r\nsample = 'I will go.'\r\n<\/pre>\n<p>\uc704\uc758 \ubb38\uc7a5\uc744 \uad6c\uc131\ud558\ub294 \uc54c\ud30c\ubcb3 \uc911\uc5d0\uc11c \uc911\ubcf5\ub418\uc9c0 \uc54a\ub294 \uace0\uc720\ud55c \uc54c\ud30c\ubcb3\ub9cc\uc744 \ucd94\ucd9c\ud558\uba74..<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\">\r\nuniq_chars = set(sample) # {'w', ' ', 'o', 'i', 'l', '.', 'g', 'I'}\r\n<\/pre>\n<p>\uc704\uc758 \ucd94\ucd9c\ub41c \uacb0\uacfc\ub294 set\uc774\ubbc0\ub85c \uc774\ub97c list\ub85c \ub9cc\ub4e4\uba74..<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\">\r\nidx2char = list(uniq_chars) # ['w', ' ', 'o', 'i', 'l', '.', 'g', 'I']\r\n<\/pre>\n<p>\uc778\ub371\uc2a4 \uac12\uc744 Value\ub85c, \ud574\ub2f9 \uc778\ub371\uc2a4\uc758 \uc54c\ud30c\ubcb3\uc744 Key\ub85c \uad6c\uc131\ub41c \ub370\uc774\ud130\ub294 \ub2e4\uc74c\ucc98\ub7fc \uc5bb\uc744 \uc218 \uc788\ub2e4.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\">\r\nchar2idx = {c: i for i, c in enumerate(idx2char)} # {'w': 0, ' ': 1, 'o': 2, 'i': 3, 'l': 4, '.': 5, 'g': 6, 'I': 7}\r\n<\/pre>\n<p>\uc774\uc81c \ucc98\uc74c \ubb38\uc7a5(sample \ubcc0\uc218)\uc744 \uc778\ub371\uc2a4 \uac12\uc73c\ub85c \uad6c\uc131\ub41c list\ub294 \ub2e4\uc74c\uacfc \uac19\ub2e4.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\">\r\nsample_idx = [char2idx[c] for c in sample] # [7, 1, 0, 3, 4, 4, 1, 6, 2, 5]\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\uba3c\uc800 \ub2e4\uc74c\uacfc \uac19\uc740 \ubb38\uc7a5\uc774 \uc788\ub2e4\uace0 \ud558\uc790. sample = &#8216;I will go.&#8217; \uc704\uc758 \ubb38\uc7a5\uc744 \uad6c\uc131\ud558\ub294 \uc54c\ud30c\ubcb3 \uc911\uc5d0\uc11c \uc911\ubcf5\ub418\uc9c0 \uc54a\ub294 \uace0\uc720\ud55c \uc54c\ud30c\ubcb3\ub9cc\uc744 \ucd94\ucd9c\ud558\uba74.. uniq_chars = set(sample) # {&#8216;w&#8217;, &#8216; &#8216;, &#8216;o&#8217;, &#8216;i&#8217;, &#8216;l&#8217;, &#8216;.&#8217;, &#8216;g&#8217;, &#8216;I&#8217;} \uc704\uc758 \ucd94\ucd9c\ub41c \uacb0\uacfc\ub294 set\uc774\ubbc0\ub85c \uc774\ub97c list\ub85c \ub9cc\ub4e4\uba74.. idx2char = list(uniq_chars) # [&#8216;w&#8217;, &#8216; &#8216;, &#8216;o&#8217;, &#8216;i&#8217;, &#8216;l&#8217;, &#8216;.&#8217;, &#8216;g&#8217;, &#8216;I&#8217;] \uc778\ub371\uc2a4 &hellip; <\/p>\n<p class=\"link-more\"><a href=\"http:\/\/www.gisdeveloper.co.kr\/?p=8141\" class=\"more-link\">\ub354 \ubcf4\uae30<span class=\"screen-reader-text\"> &#8220;[Python] \uc54c\ud30c\ubcb3\uc744 \uc778\ub371\uc2a4\ub85c \uad6c\uc131\ud558\uae30&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[131],"tags":[],"class_list":["post-8141","post","type-post","status-publish","format-standard","hentry","category-python"],"_links":{"self":[{"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/8141","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=8141"}],"version-history":[{"count":4,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/8141\/revisions"}],"predecessor-version":[{"id":9383,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/8141\/revisions\/9383"}],"wp:attachment":[{"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=8141"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=8141"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=8141"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}