Форум сайта python.su
В общем, нужно мне заменить, для примера, все русские буквы “ж” на “lalala”. Делаю так:
textToWork = u"авпж"
textToWork.replace(u'ж', 'lalala')
print textToWork
Офлайн
Help on built-in function replace:
replace(...)
S.replace (old, new[, count]) -> string
Return a copy of string S with all occurrences of substring
old replaced by new. If the optional argument count is
given, only the first count occurrences are replaced.
textToWork = u"авпж"
result = textToWork.replace(u'ж', 'lalala')
print result
Офлайн
Спасибо, работает!
Офлайн