除了 我所写的指针去空格方法,还有没有其他的方法能去字符串空格?
另外,如果用python来解决去空格应该怎么写?
str = "aaa bbb ccc"
# 方法一:replace() 方法把字符串中的 old(旧字符串) 替换成 new(新字符串),如果指定第三个参数max,则替换不超过 max 次。 str.replace(old, new[, max])
str.replace(" ", "")
# 方法二:strip()用于移除字符串头尾指定的字符(默认为空格或换行符)。
str.strip()