SORU
28 Mayıs 2009, PERŞEMBE


Python Büyük / Küçük Harf Duyarlı Değiştirin

Python ile büyük küçük harf duyarlı dize değiştirme yapmak için en kolay yolu nedir?

CEVAP
28 Mayıs 2009, PERŞEMBE


string Bu türü desteklemiyor. Muhtemelen re.IGNORECASE seçeneği the regular expression sub method kullanarak en iyi kapalı.

>>> import re
>>> insensitive_hippo = re.compile(re.escape('hippo'), re.IGNORECASE)
>>> insensitive_hippo.sub('giraffe', 'I want a hIPpo for my birthday')
'I want a giraffe for my birthday'

Bunu Paylaş:
  • Google+
  • E-Posta
Etiketler:

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • humanHardDrive

    humanHardDri

    16 Mart 2011
  • Learn Math Tutorials

    Learn Math T

    20 Kasım 2011
  • PlayStation

    PlayStation

    16 Aralık 2005