Python---list lists with string list (), Split (), join ()

Source: Internet
Author: User

1. Using the list method to convert a string to a character list, the list function converts the string to a separate letter

650) this.width=650; "src=" Https://s5.51cto.com/wyfs02/M00/8F/62/wKiom1jcnIuAS2YyAAAIKyYOUwI949.png "title=" List-str. PNG "alt=" Wkiom1jcniuas2yyaaaikyyouwi949.png "/>

2. Use Split () to convert a string into a sequence of words

650) this.width=650; "src=" Https://s4.51cto.com/wyfs02/M01/8F/62/wKiom1jcna7B4rbEAAAI8GZVcI4312.png "title=" List-split. PNG "alt=" Wkiom1jcna7b4rbeaaai8gzvci4312.png "/>

Split () method syntax:

Str.split (str= "", Num=string.count (str)).
Parameters
    • STR--the delimiter, which defaults to all null characters, including spaces, line breaks (\ n), tabs (\ t), and so on.

    • Num--the number of splits.

Example

The following example shows how the split () function is used:

650) this.width=650; "src=" Https://s1.51cto.com/wyfs02/M01/8F/60/wKioL1jcoQuxdXR7AAAKS4aH-H4553.png "title=" Split2. PNG "alt=" Wkiol1jcoquxdxr7aaaks4ah-h4553.png "/>

The 3.join function, in contrast to the split function, is a string method, so you must specify a delimiter and use the list as a parameter

Example

650) this.width=650; "src=" Https://s2.51cto.com/wyfs02/M02/8F/62/wKiom1jcot7y_iTBAAALGAg1fqU312.png "title=" join. PNG "alt=" Wkiom1jcot7y_itbaaalgag1fqu312.png "/>


This article is from the "Quiet Program Daughter" blog, please be sure to keep this source http://emily18.blog.51cto.com/7121141/1911737

Python---list lists with string list (), Split (), join ()

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.