📜  SymPy | Python中的 Subset.subset_indices()

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

SymPy | Python中的 Subset.subset_indices()

Subset.subset_indices() :subset_indices()是一个 sympy Python库函数,它返回列表中超集中子集的索引

代码 #1:subset_indices() 示例

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

输出 :

代码 #2:subset_indices() 示例

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

输出 :