0
이 예제는 스택 오버플로에서 발견되었습니다. 나는 그것을 이해하지만 단순한 메소드 컨셉은 문자열에서 여러 개의 문자를 제거하는 것처럼 보인다.python3 : .replace()의 긴 체인이있는 문자열에서 여러 문자를 제거합니다. replace(). replace()
s = "a,b,c,d,e,f,g,h,i" s = s.strip([",", "d", "h"])
대신 :
import string exclude = set(string.punctuation) s = ''.join(ch for ch in s if ch not in exclude)
의 조정에 뭔가를 할 수있는 파이썬 3.1 내장 문자열 방법이있다
s = s.replace(",", "").replace("d", "").replace("h", "")