Python string split (string split)

Source: Internet
Author: User

Python string split methodIt is often used. For example, we need to store a long data and store it in a structured way to facilitate data retrieval and processing in the future. Of course, it can be in JSON format. However, data can also be stored in a field and separated by some identifier.

For example, the storage format is:

Format:
Name, age | Name of another user, age

Name: Haha, age: 20 | Name: Python, age: 30 | Name: FEF, age: 55

Then we can use the split method of the string object to cut the string object into a list.

A = 'name: Haha, age: 20 | Name: Python, age: 30 | Name: FEF, age: 55'

Print A. Split ('| ')

Returned results:
['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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.