Detailed examples of split and strip in python

  • 2020-06-07 04:51:26
  • OfStack

Detailed examples of split and strip in python

1 I have been confused about the functions of strip and split for a long time. In fact, strip means delete. split, on the other hand, means division.

strip() function and split() function in python understand, friends in need can refer to the following.

Both splite and strip are Python's handling of strings.

splite means to divide, to divide.


a='123456'
a.split('3')

The output is [' 12', '456']

As you can see, which character was cut was also omitted. For example, the character "3" here

strip means remove, delete.


a='123456'
a.strip('1')

So here I can run '23456'

It is worth noting that strip can only be deleted from two paragraphs, not from the middle.

Without changing the original string. This method is rarely used in practice.

Thank you for reading, I hope to help you, thank you for your support to this site!


Related articles: