📜  SymPy | Python中的 Subset.subset()

📅  最后修改于: 2022-05-13 01:54:24.487000             🧑  作者: Mango

SymPy | Python中的 Subset.subset()

Subset.subset() :subset()是一个 sympy Python库函数,它返回当前实例表示的子集。

代码 #1:subset() 示例

# Python code explaining
# SymPy.Subset.subset()
  
# importing SymPy libraries
from sympy.combinatorics import Permutation, Cycle
from sympy.combinatorics.subsets import Subset
  
# Using from 
# sympy.combinatorics.subset.Subsets.subset()
  
# Creating Subset
a = Subset(['c', 'd'], ['geek', 'for', 'c', 'd'])
  
# subset value
print ("Subset a subset : ", a.subset)

输出 :

代码 #2:subset() 示例

# Python code explaining
# SymPy.Subset.subset()
  
# importing SymPy libraries
from sympy.combinatorics import Permutation, Cycle
from sympy.combinatorics.subsets import Subset
  
# Using from 
# sympy.combinatorics.subset.Subsets.subset()
  
# Creating Subset
a = Subset([2, 3, 4], [1, 2, 3, 4, 5])
  
# subset value
print ("Subset a subset : ", a.subset)

输出 :