I need to remove spaces from a string in python. For example.
str1 = \"TN 81 NZ 0025\" str1sp = nospace(srt1) print(str1sp) >>>TN81NZ0025
You can replace multiple spaces into a desired pattern by using following ways. Here your pattern is blank string.
import re pattern = "" re.sub(r"\s+", pattern, your_string)
or
import re pattern = "" re.sub(r" +", "", your_string)