Python String isidentifier ()

İsidentifier () yöntemi, dize Python'da geçerli bir tanımlayıcıysa True döndürür. Değilse, False döndürür.

Sözdizimi isidentifier()şöyledir:

 string.isidentifier ()

isidentifier () Parametreler

isidentifier()Yöntemin bir parametre almaz.

İsidentifier'dan Dönüş Değeri ()

isidentifier()Yöntem verir:

  • Dize geçerli bir tanımlayıcıysa doğrudur
  • Dize geçersiz bir tanımlayıcı değilse yanlış

Örnek 1: isidentifier () nasıl çalışır?

 str = 'Python' print(str.isidentifier()) str = 'Py thon' print(str.isidentifier()) str = '22Python' print(str.isidentifier()) str = '' print(str.isidentifier())

Çıktı

 True False False False

Python'da geçerli tanımlayıcının ne olduğunu öğrenmek için bu sayfayı ziyaret edin?

Örnek 2: Daha fazla isidentifier () Örneği

 str = 'root33' if str.isidentifier() == True: print(str, 'is a valid identifier.') else: print(str, 'is not a valid identifier.') str = '33root' if str.isidentifier() == True: print(str, 'is a valid identifier.') else: print(str, 'is not a valid identifier.') str = 'root 33' if str.isidentifier() == True: print(str, 'is a valid identifier.') else: print(str, 'is not a valid identifier.')

Çıktı

root33 geçerli bir tanımlayıcıdır. 33root geçerli bir tanımlayıcı değil. kök 33, geçerli bir tanımlayıcı değil.

Ilginç makaleler...