Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to get the complement of two sets by python

Shulou Source: shulou.com Published: 2022-05-31 11:13:34 09月30日 Update

In this article, the editor introduces in detail "python how to get the complement of the two sets", the content is detailed, the steps are clear, and the details are handled properly. I hope that this "python how to get the complement of the two sets" article can help you solve your doubts.

The details are as follows:

Set () syntax

Class set ([iterable])

Parameter description:

Iterable: iterable object object

Example:

> x = set ('runoob')

> y = set ('google')

> > x, y

(set (['baked,' rented, 'upright,' oiled,'n']), set (['eyed,' oiled, 'grubbed,' l'])) # duplicated deletion

> x & y # intersection

Set (['o'])

> x | y # Union

Set (['baked,' estranged, 'grubbed,' lumped, 'oily,' nasty, 'ritual,' u'])

X-y # subtraction (complement)

Set (['ritual,' baked, 'upright,' n'])

After reading this, the article "how to get the complement of two collections by python" has been introduced. If you want to master the knowledge points of this article, you still need to practice and use it yourself. If you want to know more about related articles, welcome to follow the industry information channel.

Tags: Two content articles objects proper intersection parameters difference ideas New knowledge more steps knowledge knowledge points examples articles details Industry Grammar Information Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MariaDB Microsoft Redmi Apple macOS