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

  • beautyexchange

    beautyexchan

    4 EYLÜL 2006
  • FASHTAG

    FASHTAG

    5 EYLÜL 2012
  • Propaganda Time

    Propaganda T

    19 EYLÜL 2010