python string space 삭제1 Python string 개행 삭제(rstrip) python으로 string을 처리하다보면 개행이든 space든 삭제해야하는 경우가 있다. 그럴 때 사용하는 명령어는 rstrip()이다. rstrip 예시 data_str = "test rstrip\n" data_str2 = "test rstrip \n" print( "[" + data_str.rstrip() + "]") print( "[" + data_str2.rstrip() + "]") print( "[" + data_str.rstrip('\n') + "]") print( "[" + data_str2.rstrip('\n') + "]") 결과 python3 rstrip.py [test rstrip] [test rstrip] [test rstrip] [test rstrip ] 즉, Default로 rs.. 2019. 10. 11. 이전 1 다음 반응형