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

  • Munchkin the Teddy Bear

    Munchkin the

    30 EYLÜL 2011
  • PorterRobinsonVEVO

    PorterRobins

    11 Kasım 2013
  • rtisticsdev

    rtisticsdev

    31 Mayıs 2012