<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
    <channel>
        <title>c_strength.log</title>
        <link>https://velog.io/</link>
        <description></description>
        <lastBuildDate>Mon, 04 Mar 2024 00:27:17 GMT</lastBuildDate>
        <docs>https://validator.w3.org/feed/docs/rss2.html</docs>
        <generator>https://github.com/jpmonette/feed</generator>
        <image>
            <title>c_strength.log</title>
            <url>https://images.velog.io/images/c_strength/profile/1b2f9310-86eb-11e9-9b42-656c45fa6d8b/adorable-animal-blur-406014-1.jpg</url>
            <link>https://velog.io/</link>
        </image>
        <copyright>Copyright (C) 2019. c_strength.log. All rights reserved.</copyright>
        <atom:link href="https://v2.velog.io/rss/c_strength" rel="self" type="application/rss+xml"/>
        <item>
            <title><![CDATA[[Sk Shieldus Rookies 19기] 인프라 구축을 위한 파이썬 - 1 파이썬 유용한 문자열 메소드(클라우드 기반 스마트 융합보안 과정)]]></title>
            <link>https://velog.io/@c_strength/Sk-Shieldus-Rookies-19%EA%B8%B0-%EC%9D%B8%ED%94%84%EB%9D%BC-%EA%B5%AC%EC%B6%95%EC%9D%84-%EC%9C%84%ED%95%9C-%ED%8C%8C%EC%9D%B4%EC%8D%AC-1-%ED%8C%8C%EC%9D%B4%EC%8D%AC-%EC%9C%A0%EC%9A%A9%ED%95%9C-%EB%AC%B8%EC%9E%90%EC%97%B4-%EB%A9%94%EC%86%8C%EB%93%9C%ED%81%B4%EB%9D%BC%EC%9A%B0%EB%93%9C-%EA%B8%B0%EB%B0%98-%EC%8A%A4%EB%A7%88%ED%8A%B8-%EC%9C%B5%ED%95%A9%EB%B3%B4%EC%95%88-%EA%B3%BC%EC%A0%95</link>
            <guid>https://velog.io/@c_strength/Sk-Shieldus-Rookies-19%EA%B8%B0-%EC%9D%B8%ED%94%84%EB%9D%BC-%EA%B5%AC%EC%B6%95%EC%9D%84-%EC%9C%84%ED%95%9C-%ED%8C%8C%EC%9D%B4%EC%8D%AC-1-%ED%8C%8C%EC%9D%B4%EC%8D%AC-%EC%9C%A0%EC%9A%A9%ED%95%9C-%EB%AC%B8%EC%9E%90%EC%97%B4-%EB%A9%94%EC%86%8C%EB%93%9C%ED%81%B4%EB%9D%BC%EC%9A%B0%EB%93%9C-%EA%B8%B0%EB%B0%98-%EC%8A%A4%EB%A7%88%ED%8A%B8-%EC%9C%B5%ED%95%A9%EB%B3%B4%EC%95%88-%EA%B3%BC%EC%A0%95</guid>
            <pubDate>Mon, 04 Mar 2024 00:27:17 GMT</pubDate>
            <description><![CDATA[<h1 id="1-개요">1. 개요</h1>
<p>문자열 객체의 유용한 메소드를 알아보자.</p>
<iframe src="https://giphy.com/embed/PkD8o1I8w55aE" width="480" height="378" frameBorder="0" class="giphy-embed" allowFullScreen></iframe><p><a href="https://giphy.com/gifs/ascii-en-imgenes-PkD8o1I8w55aE">via GIPHY</a></p>

<br>

<h1 id="2-문자열-찾기">2. 문자열 찾기</h1>
<h2 id="find">find()</h2>
<p>문자열 안에서 찾고자 하는 문자의 첫번째로 등장하는 인덱스를 반환한다. 만약, 찾고자 하는 문자가 없다면 -1을 반환한다.</p>
<pre><code class="language-python">news = &quot;North Korean factories making arms for Russia...&quot;
news.find(&quot;K&quot;) # 출력 : 6 (North Korean 의 K 인덱스 6이 반환)
news.find(&quot;!&quot;) # 출력 : -1</code></pre>
<br>

<h2 id="index">index()</h2>
<p>앞에서 확인한 find() 메소드와 동일하지만, 문자열에 없는 문자를 찾으려 할 때는 ValueError를 일으킨다.</p>
<pre><code class="language-python">news = &quot;North Korean factories making arms for Russia...&quot;
news.index(&quot;K&quot;) # 출력 : 6 (North Korean 의 K 인덱스 6이 반환)
news.index(&quot;!&quot;)
# Traceback (most recent call last):
#   File &quot;&lt;stdin&gt;&quot;, line 1, in &lt;module&gt;
# ValueError: substring not found</code></pre>
<p><br><br></p>
<h1 id="3-문자열-바꾸기">3. 문자열 바꾸기</h1>
<h2 id="replace">replace()</h2>
<p>replace(old, new) 메소드는 인자 2개를 받게 되며, 첫번째 인수는 바꾸려고 하는 대상, 두번째는 무엇으로 바꿀건지 값을 넣으면 된다.</p>
<pre><code class="language-python">news = &quot;North Korean factories making arms for Russia...&quot;
news.replace(&quot;Russia&quot;,&quot;USA&quot;) # 출력 : &#39;North Korean factories making arms for USA...&#39;</code></pre>
<br>

<h2 id="maketrans-translate">maketrans(), translate()</h2>
<p>maketrans(old, new) 메소드는 replace와 비슷하게 인수를 넣으면 된다. 그러나 maketrans 메소드로 문자를 바꾸는 테이블을 만든 후 translate메소드를 통해 바꾸는 절차가 필요하다.</p>
<pre><code class="language-python">news = &quot;North Korean factories making arms for Russia...&quot;
table = str.maketrans(&quot;or&quot;,&quot;@#&quot;) # o는 @로, r은 #으로 치환하는 테이블
news.translate(table) # 출력 : 
&#39;N@#th K@#ean fact@#ies making a#ms f@# Russia...&#39;</code></pre>
<br>

<h2 id="strip">strip()</h2>
<p>strip() 메소드는 문장 좌, 우에 공백을 지우고 그 값을 반환한다.</p>
<pre><code class="language-python">&quot;    Korea    &quot;.strip()  # 출력 : &#39;Korea&#39;</code></pre>
<p>strip(chars) 메소드에 인수를 주게 되면, 문자열 좌우에 입력 받은 인수의 값을 지운다. 단, 인자로 입력한 문자가 지우려고 하는 자리에 없으면 그곳에서 지우는 게 끝나게 된다.</p>
<pre><code class="language-python">&quot;#....... Section 3.2.1 Issue #32 .......&quot;.strip(&quot;.#! &quot;)  # 출력 : &#39;Section 3.2.1 Issue #32&#39;
# 공식문서 참조</code></pre>
<p><br><br></p>
<h1 id="4-기타">4. 기타</h1>
<h2 id="count">count()</h2>
<p>문자열에 등장하는 특정 문자의 갯수를 반환한다.</p>
<pre><code class="language-python">news = &quot;North Korean factories making arms for Russia...&quot;
news.count(&quot; &quot;) # 출력 : 6</code></pre>
<br>

<h2 id="join">join()</h2>
<p>리스트를 문자열로 만들어 반환한다.</p>
<pre><code class="language-python">a = [&quot;a&quot;,&quot;b&quot;,&quot;c&quot;,&quot;d&quot;,&quot;e&quot;]
&#39;&#39;.join(a) # 출력 : &#39;abcde

name = [&quot;짱구&quot;, &quot;훈이&quot;, &quot;철수&quot;]
&#39;-&#39;.join(name) # 출력 : &#39;짱구-훈이-철수&#39;</code></pre>
<br>

<h2 id="split">split()</h2>
<p>split()의 인자로 입력한 문자를 기준으로 문자열을 나누고, 리스트로 반환한다.</p>
<pre><code class="language-python">news = &quot;North Korean factories making arms for Russia...&quot;
news.split(&quot; &quot;)  # 출력 : [&#39;North&#39;, &#39;Korean&#39;, &#39;factories&#39;, &#39;making&#39;, &#39;arms&#39;, &#39;for&#39;, &#39;Russia...&#39;]</code></pre>
]]></description>
        </item>
    </channel>
</rss>