In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
What are the six operation schemes of collection types in the Python dictionary? many novices are not very clear about this. In order to help you solve this problem, the following editor will explain it in detail. People with this need can come and learn. I hope you can get something.
Collection type
① uses the collection's factory methods set () and frozenset ():
> s = set ('cheeseshop') > s set ([' bookshop', 'bookshop']) > > t = frozenset (' bookshop') > t frozenset (['baked,' hacked, 'kink,' type,']) > > type (s) > type (t)
How ② updates a collection adds and removes members of the collection using various collection built-in methods and operators:
> s.add ('z') > s set (['cased,' estranged, 'hacked,' oiled, 'paired,' sworn,'z']) > > s.update ('pypi') > s set ([' clocked, 'estranged,' set, 'hogwash,' oval, 'pendant,' s.remove,'z']) > > s set (['c']) ) > > s-= set ('pypi') > s set ([' cased, 'estranged,' hacked, 'oval,' s'])
③ delete collection
Del s
④ membership (in, not in)
> s = set ('cheeseshop') > t = frozenset (' bookshop') >'k'in s False >'k'in t True >'c 'not in t True
⑤ set equivalence / non-equivalence
> s = = t False > s! = t True > u = frozenset (s) > s = = u True > set ('posh') = = set (' shop') True
⑥ difference complement / relative complement set (-) the difference complement or relative complement set of two sets (s and t) refers to a set C in which the elements belong only to the set s, not to
In the set t. There is an equivalent method for subtraction.
Difference (). > s-t set (['censor,' e'])
Symmetric difference (^): symmetric difference is the XOR of a set. The above article is the practical application step of the Python dictionary to the set type.
Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
This article mainly introduces the relevant knowledge of "how to use WeChat Mini Programs selector". The editor shows you the operation process through an actual case. The operation method is simple, fast and practical. I hope this article "how to use WeChat Mini Programs selector" can help you solve the problem. Page structure
Wechat
About us
Contact us
Product review
car news
thenatureplanet
More Form oMedia:
AutoTimes.
Bestcoffee.
SL News.
Jarebook.
Coffee Hunters.
Sundaily.
Modezone.
NNB.
Coffee.
Game News.
FrontStreet.
GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.