string

    [Python] Regular Expression : re 요약

    Regular Expression : re 요약 정규표현식(正規表現式, Regular Expression)은 문자열을 처리하는 방법 중의 하나로 특정한 조건의 substring(문자열)을 '검색'하거나 '치환'하는 과정을 특정 문자열의 pattern을 기술하는 expression을 이용하여 매우 간편하게 처리 할 수 있도록 해준다. 주요 Tasks RE를 통해 수행되는 것은 크게 다음의 세가지임. searching splitting replacing 이들 모두 특정 substring pattern에 대한 matching을 사용한다. 즉, matching, searching, splitting, replacing을 하는 방법에 대한 이해를 하면 RE를 효과적으로 사용가능하다. compiled pattern..

    [Python] str : Overloaded Operators

    Concatenation + opeartor combines its two operands. 다음과 같이, 두 문자열이 붙은 새로운 문자열을 반환한다. >>> a = 'test1' + 'test2' >>> a 'test1test1' + opeartor does not add any space between two operand strings to concate, contrast to the case of print method. print 함수에서 argument 사이에 space가 포함되는 것과 달리 문자열 그대로 사용하여 결합만이 이루어짐. Duplication 곱하기가 아닌 앞의 operand 인 str이 뒤의 operand로 주어진 숫자만큼 반복되어 concatenation이 됨. >>> 'one..

    [Python] Basic Methods of String

    Basic Methods of String 프로그래밍에서 가장 많이 다루는 데이터는 text라고 할 수 있다. Raw data에서 str(string)은 numerical data 이상으로 가장 애용되는 데이터임. preprocessing 등을 통해 해당 text data는 numerical data로 변경(주로 vector)되는 경우가 매우 많음. 과학이나 연구분야가 아닌 경우, 사실상 str문자열이 가장 많이 애용되는 raw data type이라고 볼 수 있음. 이 문서에서는 Python이 기본적으로 제공하는 str class에서 다양한 built-in method들의 사용법을 간략히 정리한다. 대소문자 처리 (~ Case Conversion) lower : 전부 소문자. upper : 전부 대문자...

    [Python] f-String

    Python : f-String Python 3.6 이후 도입됨. 기존의 중괄호 {}과 format 메소드를 사용하여 문자열 포매팅을 설정하는 방식들과 유사하지만, 더 직관적으로 문자열을 포맷팅할 수 있는 기능으로 현재는 다른 방법들보다 권장됨 이를 formatted string literals라고도 부르며, 더 간결한(succinct) 구문을 가지고 있음. Syntax Python에서 문자열을 만드는 방식과 거의 유사하나 문자열을 싸고 있는 single or double quotes에서 시작하는 quote앞에 f 나 F를 붙여주면 됨. "simple text" : 일반적인 Python 문자열 f"formatted string lietera" : f-String How to print variables ..