Analysis on the use of the join () method in Python

Source: Internet
Author: User

Analysis on the use of the join () method in Python

This article mainly introduces the use of the join () method in Python, which is the basic knowledge in getting started with Python. For more information, see

The join () method returns a string that is separated by str when a string element in the sequence is added.

Syntax

The syntax of the join () method is as follows:

?

1

Str. join (sequence)

Parameters

Sequence -- this is the order of the elements to be connected.

Return Value

This method returns a string connected to the sequence seq string. The separator between elements is a string str.

Example

The following example demonstrates the use of the join () method.

?

1

2

3

4

5

#! /Usr/bin/python

 

Str = "-";

Seq = ("a", "B", "c"); # This is sequence of strings.

Print str. join (seq );

When we run the above program, it will produce the following results:

?

1

A-B-c

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.