Articles under category Python

Python version: 3.5.2

Suppose the following is the string we want to connect to.

 String to connect to

1. + number connection

Written JS Should know

 Print (text[0] + text[1] + text[2])

output

 Heyheyfuckworld

Without considering the memory space, there is nothing to use, huge amount of data, frequent memory operation, and very cumbersome rush.

Two. Space connector

 Print (text[0] text[1] text[2])

output

 Heyheyfuckworld

I don't know why. Spaces and spaces can be connected. Is it Python exclusive to laugh and cry?

Three. Placeholder connection

Don't tell the C language. Printf ("%s", "STR");

 Print ("%s%s%s"% (text[0], text[1], text[2])

output

 Heyheyfuckworld

Four. Join function connection

In fact, we recommend the best use. Join () Efficient

 T is to connect the characters between strings to 
t ='-'
print (t.join (text)).

output

 Heyhey-fuck-world

Five. * connection

This position is used by oneself.

 STR ='abc'
str * 2

output

 Abcabc

Anyway, I don't think I can use eggs, but I can't use them now.