반응형
phrase = """
It is a really long string
triple-quoted strings are used
to define multi-line strings
"""
first_half = phrase[0:int(len(phrase)/2)+1] # 변수 ‘phrase’에 포함된 문자열의 앞 절반을 얻기
print(first_half)
산출물 (Output)
It is a really long string triple-quoted str
* len() function은 string 이 몇 개의 글자를 포함하고 있는지 계산하는데 사용됩니다. 참고: type conversion 사용하기.
반응형
'Python 배우기' 카테고리의 다른 글
string_methods.py (0) | 2016.03.06 |
---|---|
character_escaping.py (0) | 2016.03.06 |
in_operator.py (0) | 2016.03.06 |
slicing.py (0) | 2016.03.06 |
negative_indexing.py (0) | 2016.03.06 |
댓글