Python으로 문자 치환하기 str.translate


Python으로 문자 치환하기 str.translate

Python을 이용해 문자열 치환하는 방법은 흔히 잘 아는 str.replace 이와 비슷한 기능을 하는 str.translate도 있다. 원래 문자열 list가 아래처럼 있고 '\n', '\t'을 str.translate를 이용해 공백으로 바꾸고 싶으면 cols = ['\n\t\t\t\t\t\t\t\t\t2017/12\n\t\t\t\t\t\t\t\t\t\n(IFRS연결)\n', '\n\t\t\t\t\t\t\t\t\t2018/12\n\t\t\t\t\t\t\t\t\t\n(IFRS연결)\n', '\n\t\t\t\t\t\t\t\t\t2019/12\n\t\t\t\t\t\t\t\t\t\n(IFRS연결)\n', '\n\t\t\t\t\t\t\t\t\t2020/12(E)\n\t\t\t\t\t\t\t\t\t\n(IFRS..


원문링크 : Python으로 문자 치환하기 str.translate