Program Tip

대문자를 소문자로 변환하는 방법

programtip 2020. 11. 13. 23:59
반응형

대문자를 소문자로 변환하는 방법


이 질문에 이미 답변이 있습니다.

입력을 읽고 나열하는 스크립트가 있지만 대문자를 소문자로 변환하려면 어떻게해야합니까?

이것이 내가 얻은 것이다

 for words in text.readlines():
    sentence = [w.strip(',.') for w in line.split() if w.strip(',.')]
    list.append(sentence)

섹션 5.6.1 에서 Python 문자열과 관련된 더 많은 메서드와 함수를 찾을 수 있습니다 . 문서의 문자열 메서드 .

w.strip(',.').lower()

str.lower() 모든 대소 문자를 소문자로 변환합니다.


파이썬에서 문자열을 소문자로 변환하려면 다음과 같이 사용하십시오.

list.append(sentence.lower())

"python upper to lower case"를 검색 한 후 첫 번째 결과에서 이것을 발견했습니다.

참고 URL : https://stackoverflow.com/questions/7862018/how-to-convert-upper-case-letters-to-lower-case

반응형