Python基本


文字列の処理

text = input() //입력받기
text.split(":") //문자열 나누기
text[0:4] //문자열 슬라이싱

// multiline
multiline = '''
Life is good
I'm happy
'''

len(text) //문자열 길이

//문자열 인덱싱
a = "Life is good"
a[0] //L
a[-1] //d


//문자열 포맷팅
"I eat %d apples." % 3
"I eat %s apples." % "three"
"I eat %x apples." % 98 

//format 함수를 사용한 포맷팅
"I eat {0} apples.".format(3)
"I ate {number} apples. I was sick for {day} days".format(number = 10, day = 3)