English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Python 기본教程

Python 흐름 제어

Python 함수

Python 데이터 타입

Python 파일 작업

Python 객체와 클래스

Python 날짜와 시간

Python 고급 지식

Python 참고서

Python 문자열 istitle() 사용 방법 및 예제

Python 문자열 메서드

문자열에서 모든 단어의 첫 글자가 대문자이고 나머지 글자가 소문자인지 확인합니다. 만약 그렇다면 istitle()가 True를 반환하고, 그렇지 않으면 False를 반환합니다.

istitle() 메서드의 문법은 다음과 같습니다:

string.istitle()

istitle() 매개변수

istitle() 메서드는 어떤 매개변수도 가져いません.

istitle() 반환 값

istitle() 메서드 반환

  • 문자열에서 모든 단어의 첫 글자가 대문자이고 나머지 글자가 소문자인 경우 True를 반환하고, 그렇지 않으면 False를 반환합니다.

예제1:istitle()의 작동 방식

s = 'Python Is Good.'
print(s.istitle())
s = 'Python is good'
print(s.istitle())
s = 'This Is @ Symbol.'
print(s.istitle())
s = ''99 Is A Number
print(s.istitle())
s = 'PYTHON'
print(s.istitle())

이 프로그램을 실행할 때, 출력은 다음과 같습니다:

True
False
True
True
False

예제2:istitle() 사용 방법

s = 'I Love Python.'
if s.istitle() == True:
  print('istitle()가 true')
else:
  print('istitle()가 false')
  
s = 'PYthon'
if s.istitle() == True:
  print('istitle()가 true')
else:
  print('istitle()가 false')

이 프로그램을 실행할 때, 출력은 다음과 같습니다:

istitle()가 true
istitle()가 false

Python 문자열 메서드