日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > python >内容正文

python

ntp symmetric_Python使用示例设置symmetric_difference()方法

發布時間:2025/3/11 python 37 豆豆
生活随笔 收集整理的這篇文章主要介紹了 ntp symmetric_Python使用示例设置symmetric_difference()方法 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

ntp symmetric

設置symmetric_difference()方法 (Set symmetric_difference() Method)

symmetric_difference() method is used to get the list of all elements which are not common in both sets, the method is called with this set (set1) and another set (set2) is supplied as an argument.

symmetric_difference()方法用于獲取在兩個集合中都不通用的所有元素的列表,使用此集合( set1 )調用該方法,并提供另一個集合( set2 )作為參數。

Syntax:

句法:

set1.symmetric_difference(set2)

Parameter(s):

參數:

  • set2 – It represents another set to be compared with this set (set1).

    set2 –代表另一個要與此集合進行比較的集合( set1 )。

Return value:

返回值:

The return type of this method is <class 'set'>, it returns the set of those elements which are not common in both sets.

此方法的返回類型為<class'set'> ,它返回在兩個集合中都不通用的那些元素的集合。

Example 1:

范例1:

# Python Set symmetric_difference() Method with Example# declaring the sets cars_1 = {"Porsche", "Audi", "Lexus"} cars_2 = {"Porsche", "Mazda", "Lincoln"}# symmetric_difference() method call x = cars_1.symmetric_difference(cars_2)# printing the sets print("cars_1:", cars_1) print("cars_2:", cars_2) print("x:", x)

Output

輸出量

cars_1: {'Lexus', 'Audi', 'Porsche'} cars_2: {'Porsche', 'Mazda', 'Lincoln'} x: {'Lexus', 'Lincoln', 'Audi', 'Mazda'}

Example 2:

范例2:

# Python Set symmetric_difference() Method with Example# declaring the sets x = {"ABC", "PQR", "XYZ"} y = {"ABC", "PQR", "XYZ"} z = {"DEF", "MNO", "ABC"}# printing the results print("x:", x) print("y:", y) print("z:", z)# printing the result of symmetric_difference() print("x.symmetric_difference(y): ", x.symmetric_difference(y)) print("x.symmetric_difference(z): ", x.symmetric_difference(z)) print("y.symmetric_difference(x): ", y.symmetric_difference(x)) print("y.symmetric_difference(z): ", y.symmetric_difference(z)) print("z.symmetric_difference(y): ", z.symmetric_difference(y)) print("z.symmetric_difference(x): ", z.symmetric_difference(x))

Output

輸出量

x: {'XYZ', 'ABC', 'PQR'} y: {'XYZ', 'ABC', 'PQR'} z: {'MNO', 'ABC', 'DEF'} x.symmetric_difference(y): set() x.symmetric_difference(z): {'PQR', 'MNO', 'XYZ', 'DEF'} y.symmetric_difference(x): set() y.symmetric_difference(z): {'PQR', 'MNO', 'XYZ', 'DEF'} z.symmetric_difference(y): {'PQR', 'MNO', 'XYZ', 'DEF'} z.symmetric_difference(x): {'PQR', 'MNO', 'XYZ', 'DEF'}

翻譯自: https://www.includehelp.com/python/set-symmetric_difference-method-with-example.aspx

ntp symmetric

總結

以上是生活随笔為你收集整理的ntp symmetric_Python使用示例设置symmetric_difference()方法的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。