Usage sharing of python string split
- 2020-04-02 09:49:03
- OfStack
For example, the format of our storage:
Format:
Name, age | another user name, age
Name: haha, age: 20 | name: python, age: 30 | name: fef, age: 55
So we can cut the string object into a list by the split method of the string object.
A = 'name: haha, age: 20 | name: python, age: 30 | name: fef, age: 55'
Print a.s plit (' | ')
Return result:
[' name: haha, age: 20 ', 'name: python, age: 30', 'name: fef, age: 55]
Through the above introduction, I believe you have a good understanding of python string split