I. List Merge
The first method:
a =[91,95,97,99] b =[92,93,96,98] c = a+b # Merge () # Sort, sort, sort # print(c) (reverse=True) # Sorting in reverse order print(c)
The second method:
a =[91,95,97,99] b =[92,93,96,98] a[0:0] = b # Merge () print(a)
The third method:
a =[91,95,97,99] b =[92,93,96,98] a += b # Merge () print(a)
Fourth method:
a =[91,95,97,99] b =[92,93,96,98] (b) # Merge () print(a)
Fifth method:Here the entire list b is put into a. It is not recommended to use the
a =[91,95,97,99] b =[92,93,96,98] (b) # Merge print(a)
II. str Merge
The first:
a = 'You call:' b = 'Little Ming' print(a+b)
The second:
a = 'You call:' b = 'Little Ming' print("%s%s" % (a, b))
III. Dict Merge
The first:
y = {'a': 10, 'b': 8} t = {'d': 6, 'c': 4} # Merge t and into y (t) print(y)
The second:
y = {'a': 10, 'b': 8} t = {'d': 6, 'c': 4} print({**y, **t}) # dictionary splitting,keywords
The third:
y = {'a': 10, 'b': 8} t = {'d': 6, 'c': 4} f = dict(y) # Dictionary constructor (t) # Updates print(f)
The fourth:
y = {'a': 10, 'b': 8} t = {'d': 6, 'c': 4} c = dict(list(()) + list(())) print(c)
To this point, this article on the sharing of several python variable merger method of the article is introduced to this, more related python variable merger content please search for my previous articles or continue to browse the following related articles I hope you will support me in the future more!