Get the App
SLTechnology News&Howtos  ›  Development  › 

What are the related operations of the Python collection

Shulou Source: shulou.com Published: 2022-06-01 07:53:10 11月30日 Update

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!

Tags: Articles elements content not much functions most introductions ways more knowledge industry information information channels channels references learning help generation Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Information Redmi Huawei macOS MariaDB