text = "Test~123" print(text) Displays:
Test~123 And you need to do so that when the output was "Test 123"
Those. remove the sign and replace it with a space
Try:
>>> print(text.replace('~', ' ')) Test 123
If you type the query python string replace on Google.com, then we come to the document string.replace (s, old, new [, maxreplace] .
Your solution would be text.replace('~', ' ') .
You can also try a regular expression in this case it deletes all characters except letters and numbers.
import re rep = re.compile("[^a-zA-Zа-яА-я,\d]") text = rep.sub(" ", "Test~123") print(text) # Test 123 Source: https://ru.stackoverflow.com/questions/811722/
All Articles