RegEx를 사용하지 않고 Python 문자열의 시작 부분에서 알파벳이 아닌 모든 문자를 제거하십시오.

mribot

많은 단어가 시끄러운 단어 목록이 있습니다. 시끄럽다는 것은 ' "', '-'와 같은 알파벳이 아닌 문자로 시작한다는 것을 의미합니다. 예 :"thisword, -thisword,- "this word, .thisword 및 다른 여러 단어가 될 수 있습니다.

ascii를 사용하여 제거 할 수 있습니다.

from string import ascii letter
string.lstrip(ascii_letters)  

정규 표현식을 사용하지 않고 non_ascii를 처리 할 수있는 유사한 방법이 파이썬에 있습니까?

감사!

nu11p01n73R

string.puctuation 을 사용하지 않는 이유

>>> from string import punctuation
>>> "-asdf".lstrip(punctuation)
'asdf'
>>> "'asdf".lstrip(punctuation)
'asdf'
>>> '"asdf'.lstrip(punctuation)
'asdf'
>>> ',asdf'.lstrip(punctuation)
'asdf'

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

Related 관련 기사

뜨겁다태그

보관