What are the related operations of the Python collection
Editor to share with you what are the relevant operations of the Python collection, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!
Introduction
I. how to create a collection
# use {} s = {1 range 2) 3 Jing 4 3 Jing 2} # do not allow repeating elements print (s) # use the built-in function set () s = set (range (6)) print (s) print (set (range (9) print (set ([10 Magi 12 Magneto 13) 4]) print (set ('Python')) II, related operations of the set
Set = {10print (10 in set) # New Operation # add () set.add (80) print (set) # update () set.update ([60print 70Pen90]) print (set) # Delete operation # removeset.remove (80) print (set) # pop delete one element at a time set.pop () print (set) # clearset.clear () print (set) 3, set generation
The above is all the contents of the article "what are the related operations of the Python collection?" 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!