Ja virkne ir virkne ar titulu, atgriež vērtību True. Ja nē, tas atgriež False.
Metodes sintakse istitle()
ir:
string.istitle ()
istitle () parametri
istitle()
Metode neveic nekādus parametrus.
Atgriešanās vērtība no istitle ()
The istitle()
metode atgriež:
True
ja virkne ir titrēta virkneFalse
ja virkne nav titrēta virkne vai tukša virkne
1. piemērs: istitle () darbība
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())
Rezultāts
Patiess nepatiesa patiess nepatiesa
2. piemērs: Kā lietot istitle ()?
s = 'I Love Python.' if s.istitle() == True: print('Titlecased String') else: print('Not a Titlecased String') s = 'PYthon' if s.istitle() == True: print('Titlecased String') else: print('Not a Titlecased String')
Rezultāts
String Titlecased Nav String Titlecased