【问题标题】:I would like to have a clarification about Python's issubset method我想澄清一下 Python 的 issubset 方法
【发布时间】:2019-09-12 18:39:51
【问题描述】:

我有这个sn-p:

DNA = ['A', 'C', 'G', 'T', 'N']
sequence = ''
set(sequence.upper()).issubset(DNA)

我有一个True 作为回应。我想澄清一下为什么?因为'' 不是DNA 的一部分。文档说:如果迭代为空,则返回False

【问题讨论】:

  • 请使用通用 [python] 标签标记所有与 python 相关的问题。您可以自行决定使用特定于版本的标签,通常,现在假定使用 Python 3

标签: python python-3.x methods


【解决方案1】:

set(sequence.upper())set()(空集),空集是每个集合的子集。

来自Docs

issubset(other)
set <= other
测试集合中的每个元素是否都在其他元素中。

set < other
测试该集合是否是其他集合的真子集,即set <= otherset != other

【讨论】:

  • 忘记了基本的数学运算。
猜你喜欢
  • 2011-03-17
  • 2021-07-11
  • 2017-01-18
  • 1970-01-01
  • 2022-11-09
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多