관리 메뉴

A seeker after truth

[python] .join() 본문

Programming Language/Python

[python] .join()

dr.meteor 2020. 1. 13. 15:06

split과 반대로 얘는 리스트를 문자열로 바꾸는 기능이다!

 파라미터로 iterable 객체 뿐 아니라 문자 자체도 받는다. 그럼 문자 사이사이에 "~". 가 들어가는 것.

ex1)

>>> time_list = ['10', '34', '17']

>>> ':'.join(time_list)

'10:34:17'

 

ex2)

>>> ','.join(['a','b','cde'])

'a,b,cde'

 

좀더 어려운 / 기막힌 예시는 아래 링크의 class canvas, def display 파트에 있다!

https://anandology.com/python-practice-book/object_oriented_programming.html