The python strip () method

python in the string str strip () method

str.strip () is to space string (str) of the head and tail as well as head and tail located \ n \ t like to delete.

Example 1:

str=" python  "
print(str.strip())
--->
python

Example 2:

str2 = "\n AAAA"
print(str2)
print(str2.strip())
--->

 AAAA
AAAA

Example 3:

a= "\n ABC ABC ABC =========>KLJIFLJI \t \n"
print(a)
print(a.strip())
--->

 ABC ABC ABC =========>KLJIFLJI

ABC ABC ABC =========>KLJIFLJI

Note: Do not grab the middle of a string space, just grab the head and tail

Guess you like

Origin www.cnblogs.com/-chenxs/p/11408453.html