Python-Ref > Data structures > Sequence types in general > Sequence concatenation
 
 

<-^^
Klíčová slova
Moduly
Knihovní funkce

Sequence concatenation

To concatenate two or more sequences, the + operator might be used.
Expand/Shrink
Zdroj: (sequence5-1.py)
  1   list1 = [0,1,4,2,4]
  2   list2 = [200,404]
  3   str1 = "One"
  4   str2 = "two"
  5   tup1 = (1,2,3)
  6   tup2 = ("text",5)
  7   
  8   list3 = list1 + list2
  9   print list3
 10   
 11   print str1 + str2
 12   str1 += str2
 13   print str1
 14   print str1 + str2
 15   
 16   print tup1 + tup2
stdout:
[0, 1, 4, 2, 4, 200, 404]
Onetwo
Onetwo
Onetwotwo
(1, 2, 3, 'text', 5)
Doba běhu: 21.0 ms