파이썬 공백2개 제거

import re t_str = '에어팟3 [애플] 2020년2월14일 출시'; if __name__ == '__main__': pattern = re.compile(r'\s\s+') print(t_str) startIdx = t_str.find('[') tit = "" if startIdx > -1: endIdx = t_str.find(']') first_tit = t_str[startIdx:endIdx+1] last_tit = t_str.replace(first_tit,"") title_nm_space = "{}{}".format(first_tit,last_tit) print(title_nm_space) title_nm = re.sub(pattern, ' ', title_nm_space) print(title_nm)
pattern = re.compile(r'\s\s+')
정규식을 이용해 2개공백을 1개공백으로 변경.

Popular posts from this blog

com.gpki.secureweb.GPKISecureWEBException: ErrCode=1507,ErrMsg=[GPKI_CMS_ProcessEnvelopedData] 해당 인증서로는 데이터를 풀 수 없습니다.

PL/SQL Developer Tip 선택한 것만 실행

전자정부 EgovMap Xml Jsp