集合 (set) 與原封集合 (frozenset) 型態 (type) 的 isdisjoint() 方法 (method) ,判斷 s1 與 s2 是否無交集,若無交集,回傳 True
方法 | 描述 |
s1.isdisjoint(s2) | 判斷 s1 與 s2 是否無交集,若無交集,回傳 True |
舉例示範如下
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | a = { "a" , "b" , "c" }
print (a)
print ( type (a))
print ()
b = frozenset ({ "a" , "b" , "c" , "1" , "2" })
print (b)
print ( type (b))
print ()
c = set ()
print (c)
print ( type (c))
print ()
print (a.isdisjoint(b))
print (a.isdisjoint(c))
print (b.isdisjoint(a))
print (b.isdisjoint(c))
print (c.isdisjoint(a))
print (c.isdisjoint(b))
|
執行結果如下
中英文術語對照 |
集合 | set |
原封集合 | frozenset |
型態 | type |
方法 | method |
內建型態
- 數字型態 int float complex 按一下展開目錄
- 迭代器型態
- 序列型態 按一下展開目錄
- 字串 str 按一下展開目錄
- str.capitalize()
- str.center(width[, fillchar])
- str.count(sub[, start[, end]])
- str.encode(encoding="utf-8", errors="strict")
- str.endswith(suffix[, start[, end]])
- str.expandtabs([tabsize])
- str.find(sub[, start[, end]])
- str.format(*args, **kwargs)
- str.index(sub[, start[, end]])
- str.isalnum()
- str.isalpha()
- str.isdecimal()
- str.isdigit()
- str.isidentifier()
- str.islower()
- str.isnumeric()
- str.isprintable()
- str.isspace()
- str.istitle()
- str.isupper()
- str.join(iterable)
- str.ljust(width[, fillchar])
- str.lower()
- str.lstrip([chars])
- static str.maketrans(x[, y[, z]])
- str.partition(sep)
- str.replace(old, new[, count])
- str.rfind(sub[, start[, end]])
- str.rindex(sub[, start[, end]])
- str.rjust(width[, fillchar])
- str.rpartition(sep)
- str.rsplit([sep[, maxsplit]])
- str.rstrip([chars])
- str.split([sep[, maxsplit]])
- str.splitlines([keepends])
- str.startswith(prefix[, start[, end]])
- str.strip([chars])
- str.swapcase()
- str.title()
- str.translate(map)
- str.upper()
- str.zfill(width)
- range
- 串列 list 按一下展開目錄
- 序對 tuple
- 字節 bytes 按一下展開目錄
- 字節陣列 bytearrary 按一下展開目錄
- 集合型態 set frozenset 按一下展開目錄
- 配對型態 dict 按一下展開目錄
沒有留言:
張貼留言