Example of join and split usage in Python, pythonjoin

Source: Internet
Author: User

Example of join and split usage in Python, pythonjoin

Join is used to connect strings. split is the opposite.
I don't need to explain it much. After reading the code, I can see it myself.
Copy codeThe Code is as follows:
>>> Li = ['my, 'name', 'is, 'bob']
>>> ''. Join (li)
'My name is bob'
>>> S = '_'. join (li)
>>> S
'My _ name_is_bob'
>>> S. split ('_')
['My, 'name', 'is, 'bob']

The English versions of join and split are as follows:

Join (...)
S. join (sequence)-> string

Return a string which is the concatenation of the strings in
Sequence. The separator between elements is S.

Split (...)
S. split ([sep [, maxsplit])-> list of strings

Return a list of the words in the string S, using sep as
Delimiter string. If maxsplit is given, at most maxsplit
Splits are done. If sep is not specified or is None, any
Whitespace string is a separator and empty strings are removed
From the result.

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.