Get the App
SLTechnology News&Howtos  ›  Development  › 

What are the methods of variable merging in python

Shulou Source: shulou.com Published: 2022-06-01 04:43:21 09月11日 Update

This article mainly shows you "what are the methods of variable merging in python", the content is simple and clear, and I hope it can help you solve your doubts. Let me lead you to study and learn about "what are the methods of variable merging in python".

I. list merger

The first method:

A = [91 c.sort 95 c.sort (reverse=True) # sort reverse order print (c))

The second method:

A = [91 a.sort 95 print 99] b = [92 recollection 93 Reagin 96 Magazine 98] a [0:0] = b # merge Jet ()

The third method:

A = [91 print 95, 97 print 99] b = [92, 93, 96, and 98] a + = b # merge ()

The fourth method:

A = [91 print 95 print 97 print 99] b = [92 recollection 93 repartee 96 Magazine 98] GetWord (b) # amalgamated a.sort ()

The fifth method: here is to put the entire list b into a, not recommended

A = [91pr 95pr 97je 99] b = [92pr 93pr 96m 98] a.append (b) # merge print (a) II, str merge

The first kind:

A = 'your name is:' B = 'Xiao Ming' print (axib)

The second kind:

A = 'your name:' b = 'Xiao Ming' print ("% s% s"% (a, b)) 3. Dict merger

The first kind:

Y = {'averse: 10,' baked: 8} t = {'daddy: 6,' croup: 4} # merge t into y and y.update (t) print (y)

The second kind:

Y = {'axie: 10,' baked: 8} t = {'daddy: 6,' cession: 4} print ({* * y, * * t}) # dictionary split, keyword

The third kind:

Y = {'aquired: 10,' baked: 8} t = {'dashed: 6,' cached: 4} f = dict (y) # dictionary constructor f.update (t) # Update print (f)

The fourth kind:

Y = {'averse: 10,' baked: 8} t = {'daddy: 6,' centering: 4} c = dict (list (y.items ()) + list (t.items () print (c) the above are all the contents of the article "what are the methods of variable merging in python". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Tags: Methods variables content articles dictionaries Xiaoming learning help sorting reverse order keywords keywords suggestions easy to understand more organization knowledge editing industry information Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Huawei Shulou Technology Xiaomi macOS OPPO Reno