파이썬에서 문자열은 ""를 이용하여 정의할 수 있다.

s = "Hello World"
print(s)


Accesing array elements

대괄호를 이용하여 문자열의 요소에 엑세스

print(s[0])


String Slicing

파이썬에서는 문자열을 범위를 지정하여 Substring 할 수 있다.

문자열을 자를 인덱스 범위를 3가지 방법으로 지정 할 수 있다.

>>> s = "Hello World"
>>> s[:3]
'Hel'
>>> s[3:]
'lo World'
>>> s[1:3]
'el'
>>> slice = s[0:5]
'hello'


'프로그래밍 > Python' 카테고리의 다른 글

Python Tutorial : Comments [15]  (0) 2016.04.16
Python Tutorial : Date and Time [14]  (0) 2016.04.16
Python Tutorial : Modules [13]  (0) 2016.04.16
Python Tutorial : Line charts [12]  (0) 2016.04.16
Python Tutorial : Statistics [11]  (0) 2016.04.15

+ Recent posts