Home >Backend Development >Python Tutorial >What does join mean in python?

What does join mean in python?

(*-*)浩
(*-*)浩Original
2019-06-25 10:53:3615361browse

The join() method in Python is used to connect elements in the sequence with specified characters to generate a new string.

What does join mean in python?

join() method syntax: (recommended learning: Python video tutorial)

str.join(sequence)

Parameters

sequence -- The sequence of elements to be connected.

Return value

Returns a new string generated by concatenating elements in the sequence by the specified characters.

Examples

The following examples show how to use join():

#!/usr/bin/python
# -*- coding: UTF-8 -*-
 
str = "-";
seq = ("a", "b", "c"); # 字符串序列
print str.join( seq );

The output results of the above examples are as follows:

a-b-c

For more Python-related technical articles, please visit the Python Tutorial column to learn!

The above is the detailed content of What does join mean in python?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn