Because of the effects of other languages, some places are still not used to it.
A truncated string is one example.
Left, right, first no longer explained, because the function can be used directly.
The main record of the middle space processing.
Method 1:
' ... \0....\0 ... '. Replace (' the ', ')
This is not very good, not only because of the coding problem (2.x version of the use of repr () can see the space corresponding to the encoding, with its replacement), and too cumbersome, inflexible
Method 2:
Strip (), if this method can work directly, it will save a lot of trouble, but the effect, who knows. In most cases, it doesn't work.
Method 3:
Split first, then join.
s = ' China Tall program Ape is purely ... '
x = S.split (')
y = '. Join (x)
It seems to be troublesome, but very effective;
This can also be written in Jane:
'. Join ([x for x in S if x!= "])
On and off, hehe, very in accordance with the natural law Ah,
If there is a more agile, more convenient way to achieve, please leave a message.