Python 1日目-リソース型


-문자열에 작은따옴표 (') 포함시키기
`>>> food = "Python's favorite food is perl"`

-문자열에 큰따옴표 (") 포함시키기
`>>> say = '"Python is very easy." he says.'`

-백슬래시(\)를 사용해서 작은따옴표(')와 큰따옴표(")를 문자열에 포함시키기
`>>> food = 'Python\'s favorite food is perl'`
`>>> say = "\"Python is very easy.\" he says."`

-문자열 곱하기
print("=" * 50)
print("My Program")
print("=" * 50)

-인덱싱
>>> a = "Life is too short, You need Python"
>>> b = a[0] + a[1] + a[2] + a[3]
>>> b
'Life'
>>> a[-2]
'o'
>>> a[-5]
'y'


-슬라이싱
>>> a[0:3]
'Lif'

a[0:3]을 수식으로 나타내면 다음과 같다.
0 <= a < 3