나의 공부/프로그래밍 언어
Python) join(), split()
내가 Nega
2022. 1. 3. 15:41
728x90
join()
튜플, 리스트, stirng 등 반복 가능한 iterable 객체를 받는 메서드입니다.
각각의 원소를 모아 하나의 문자열로 합쳐줍니다.
"요소 연결시 추가할 문자".join(iterable객체)
#- join()
alphabet = ['a', 'b', 'c']
",".join(alphabet)
실행 결과
'a,b,c'
split()
#- split()
>>> "hi this is me".split()
['hi', 'this', 'is', 'me']
>>> "this,is,me!".split(',')
['this', 'is', 'me!']
>>>
반응형