How Python connects Strings

Source: Internet
Author: User
The Python connection string was found to be useless, affecting the speed 1. Concatenation of characters by numbers
S= ""  #定义这个字符串, easy to do connection print type (s) for I in range:    print i    type (i)    s+=str (i)  #转换类型在对接print s

2. character concatenation of characters

String= "abcdef" for I in string:    print i+ ' June '  directly using string connection

3. Concatenation of lists and strings

list1=[' Hello ', ' its ', ' OK ']print ' jun* '. Join (List1) #主要是使用这个join这个函数

4. Dictionary and string concatenation

The dictionary must be converted to STR type

dict1={' 1 ': ' A ', ' 2 ': ' B ', ' 3 ': ' C '}str1=str (dict1) print type (STR1) str1+= ' June ' Print Str1type (str1)

How Python connects Strings

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.