티스토리 뷰

공부

[Python] trim ==> strip 공백제거

승가비 2020. 4. 3. 00:01
728x90
# https://stackoverflow.com/questions/1185524/how-do-i-trim-whitespace 

# 양쪽 공백 제거 
s = " \t a string example\t " s = s.strip() 

# 오른쪽 공백 제거 
s = s.rstrip() 

# 왼쪽 공백 제거 
s = s.lstrip()

# 정규식 
import re pat = re.compile(r'\s+') 
s = ' \t foo \t bar \t ' 
print pat.sub('', s)

# prints "foobar"

https://bluesid.tistory.com/337

 

[python] 파이썬 trim 트림 whitespace 제거 공백 제거

python에서 공백 제거와 관련된 코드

bluesid.tistory.com

 

728x90

'공부' 카테고리의 다른 글

[Github] README.md show image  (0) 2020.04.03
[Python] requests UserAgent  (0) 2020.04.03
[Git] Semantic Commit Messages  (0) 2020.04.02
[Heroku] Python App not compatible with buildpack  (0) 2020.04.02
[Python] try & except  (0) 2020.04.02
댓글