python 에서 텍스트를 처리할 때 특수문자를 제거해야 할 때가 있습니다. 이럴 때 정규표현식 으로 처리할 수도
있지만 다음과 같이 처리할 수도 있습니다.
sampleString = "1234567890abcdefgABCDEFG!@#$%^&*()_{}[]<>" resultString = "" for c in sampleString: if c.isalnum(): resultString +=c print resultString
결과는
1234567890abcdefgABCDEFG
[Finished in 0.2s]
'Python' 카테고리의 다른 글
[Python] Sublime Text 2 [Decode error - output not utf-8] (0) | 2014.11.19 |
---|---|
[python] python MySQL 연동 시 update 혹은 insert를 실행해도 update 및 insert 가 되지 않을 때 (0) | 2014.10.30 |
[python] dictionary 에 key 값 존재 유무 (0) | 2014.10.30 |
[python] 리스트 중복 제거 (0) | 2014.10.27 |
[python] 정규 표현식 대문자 2개 이상 (이니셜 매치) (0) | 2014.10.27 |