Source code for str.replace() - Python Discussions
Jul 27, 2026 ... Can anyone tell me where I might find the underlying C source code for Python's builtin str.replace() method? Not that I know much about C ...
Jul 27, 2026 ... Can anyone tell me where I might find the underlying C source code for Python's builtin str.replace() method? Not that I know much about C ...
I have Python 3.11 on Windows 10. I’m still fairly new to Python. I have a string with data I got from a website. The website uses an extended ascii character for the minus sign and I’d like to change that to a normal printable dash. The next value of the odd character is \x2212.
Syntax of the method: str.replace(old, new, count=-1). What if replace could accept two lists instead of two strings. Often I find in code: text.replace(a, b).replace(c, d).
Discussions on Python.org. Python Replace String in json output.Instead, parse the JSON into Python (json.loads) and modify the resulting structure and put it back. There are too many opportunities to get text replacement wrong.
Discussions on Python.org. Feature Proposal: Multi-String Replacement Using a Dictionary in the .replace() Method. Ideas. HicaroD (Hicro).
Your code starts with blankword being set to an empty list, but then later it is set to a string. Strings and lists don’t behave the same way. Strings are immutable, so there’s no syntax to “change” the letter at a position in a string.