반응형
monty_python = "Monty Python"
monty = monty_python[:5] # one or both index could be dropped. monty_python[:5] is equal to monty_python[0:5]
print(monty)
python = monty_python[6:12]
print(python)
산출물 (Output)
Monty Python
* Slicing을 이용하여 string으로부터 복수의 글자들(substring)을 얻습니다.
슬라이싱의 신택스는 indexing의 신택스와 비슷하지만, 1개의 인텍스 대신 colon으로 구분되는 2개의 indices (숫자들)를 사용합니다(예, str[ind1:ind2]).
반응형
'Python 배우기' 카테고리의 다른 글
len_function.py (0) | 2016.03.06 |
---|---|
in_operator.py (0) | 2016.03.06 |
negative_indexing.py (0) | 2016.03.06 |
string_indexing.py (0) | 2016.03.06 |
string_multiplication.py (0) | 2016.03.06 |
댓글