Skip to content

Latest commit

 

History

History
65 lines (52 loc) · 1.34 KB

File metadata and controls

65 lines (52 loc) · 1.34 KB
layout default
title String Type
parent Data type
grand_parent Python
nav_order 2

Data type String

{: .no_toc .text-beta .fw-700}

Table of contents

{: .no_toc .text-delta }

  1. TOC {:toc}

String Type

{: .no_toc}

Declare String

파이썬에서 문자열(str)이란 문자열 즉, 문자의 집합을 의미함

  • 여러줄로 문자열을 정의할 경우에는 큰 따옴표 3개 즉, """로 감싸서 정의

    예시 {: .label .label-purple .mt-2}

    ![](string.jpg)
    ```java a = '문자열 정의방법 (1) - 작은 따옴표' b = "문자열 정의방법 (2) - 큰 따옴표" c = """ 문자열 정의방법(3) - 여러줄로 정의하는 방법 하이루 반갑습니다 """ print(a,b,c,sep=",") print(type(a), type(b), type(c)) ```
  • 문자열에 작은/ 큰 따옴표를 혼합해서 정의하는 방법

    → 이스케이프 문자 사용

    예시 {: .label .label-purple .mt-2}

    ![](escape.jpg)
    ```java a = 'Python"s simple program language' b = "Python's simple program language" c = "Python\'s simple program language" d = "Python\'s simple program language"

    print(a) print(b) print(c) print(d)