我有这个片段:
DNA = ['A', 'C', 'G', 'T', 'N']
sequence = ''
set(sequence.upper()).issubset(DNA)
我有一个 True
作为回应。我想澄清一下为什么?因为 ''
不是 DNA
的一部分。文档说:如果可迭代对象为空,则返回 False
。
最佳答案
set(sequence.upper())
是set()
(空集),空集是每个集合的子集。
并且来自 Docs :
issubset(other)
set <= other
Test whether every element in the set is in other.
set < other
Test whether the set is a proper subset of other, that is,set <= other
andset != other
.
关于python - 我想澄清一下 Python 的 issubset 方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57912783/