About 346,000 results
Open links in new tab
  1. How to use string.replace () in python 3.x - Stack Overflow

    Feb 26, 2012 · Official doc for str.replace of Python 3. official doc: Python 3's str.replace. str.replace(old, new[, count]) Return a copy of the string with all occurrences of substring old …

  2. python - How to replace multiple substrings of a string ... - Stack ...

    :param str string: string to execute replacements on :param dict replacements: replacement dictionary {value to find: value to replace} :rtype: str """ # Place longer ones first to keep …

  3. python - Changing a character in a string - Stack Overflow

    Aug 4, 2009 · Python strings are immutable, you change them by making a copy. The easiest way to do what you want is probably: text = "Z" + text[1:] The text[1:] returns the string in text from …

  4. python - How can I use a dictionary to do multiple search-and …

    Dec 21, 2022 · Upon review: after removing the code attempt (which had multiple issues to the point where it might as well be pseudocode; and which doesn't help understand the question …

  5. string - Python replace function - Stack Overflow

    Feb 8, 2012 · Strings are not mutable, thus you'll never find a way to replace just one character of the string. You should use arrays to be able to replace only the nth element. Replace on …

  6. Replacing a substring of a string with Python - Stack Overflow

    @kwikness - I'm pretty sure Raymond was alluding to Guido van Rossum (python's creator and BDFL (benevolent dictator for life)), Tim Peters (TimSort fame, wrote Zen of Python), and …

  7. python - Best way to replace multiple characters in a string?

    Mar 19, 2019 · With an input string of abc&def#ghi and replacing & -> \& and # -> \#, the fastest way was to chain together the replacements like this: text.replace('&', '\&').replace('#', '\#'). …

  8. How to replace text in a string column of a Pandas dataframe?

    data["column_name"] = data["column_name"].apply(lambda x: x.replace("characters_need_to_replace", "new_characters")) lambda is more like a function …

  9. python - Replace string within file contents - Stack Overflow

    If you'd like to replace the strings in the same file, you probably have to read its contents into a local variable, close it, and re-open it for writing: I am using the with statement in this example, …

  10. python - Replacing characters in string without replace() function ...

    This is mostly a logic problem. I am trying to replace a character in a string without using the replace function. I am trying to first change it into a list, change the elements, then turn it back …

Refresh