반응형
나는 이와 같은 문자열이
>>> x="Alpha_beta_Gamma"
>>> words = [y for y in x.split('_')]
>>> words
['Alpha', 'beta', 'Gamma']
목록 단어의 두 번째 요소가 소문자로 시작하고 x = "Alpha_Beta_Gamma"
문자열이 일치하는 경우 X가 일치하지 않는다는 출력을 원합니다.
해결 방법
>>> help(str.istitle)
Help on method_descriptor:
istitle(...)
S.istitle() -> bool
Return True if S is a titlecased string and there is at least one
character in S, i.e. uppercase characters may only follow uncased
characters and lowercase characters only cased ones. Return False
otherwise.
>>> "Alpha_beta_Gamma".istitle()
False
>>> "Alpha_Beta_Gamma".istitle()
True
>>> "Alpha_Beta_GAmma".istitle()
False
참조 페이지 https://stackoverflow.com/questions/3668964
반응형
'파이썬' 카테고리의 다른 글
파이썬 Python에서 Pandas를 사용하여 일련의 숫자를 만드는 방법 (0) | 2020.11.04 |
---|---|
파이썬 다른 열 pandas 데이터 프레임을 기반으로 열 값 추출 (0) | 2020.11.04 |
파이썬 BeautifulSoup : 'Response'유형의 객체에는 len ()이 없습니다. (0) | 2020.11.04 |
파이썬 Anaconda가 HTTP 프록시 (https가 아님) 뒤에서 작동하도록하는 방법은 무엇입니까? (0) | 2020.11.04 |
파이썬 Django - The current URL, , didn't match any of these (0) | 2020.11.04 |
댓글