A summary of Python string concatenation method

Source: Internet
Author: User
Tags python string concatenation
This article mainly introduces the Python string splicing of several methods to organize the relevant data, here provides five ways and implementation, the need for friends can refer to the following

Several ways to arrange Python string concatenation

The first is the form of a plus sign (+)


Print (' The first way to connect via a plus sign: ' + ' love ' + ' Python ' + ' \ n ')

The second type is through a comma (,)


Print (' Second way to connect by comma: ' + ' love ', ' Python ' + ' \ n ')

The third type of direct connection has no space in the middle


Print (' The third way to connect via direct Connect (a): ' + ' love ' python ' + ' \ n ') print (' Third way to connect via direct connection (ii): ' + ' love '  ' python ' + ' \ n ')

The fourth type of formatting


Print (' Fourth way to connect via format: ' + '%s '%s '% (' love ', ' Python ') + ' \ n ')

Fifth Join mode connection


Str_list = [' Love ', ' Python ']print (' The fifth way to connect via join: ' + '. Join (str_list) + ' \ n ')

Run results

Related Article

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.