Sympy noob想知道如何使Sympy Permutation应用于列表。例如,
from sympy.combinatorics import Permutation
lst = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i']
perm = Permutation([[0, 2, 8, 6], [1, 5, 7, 3]])
# Then something like...
perm * lst # This doesn't work. Throws AttributeError because of list
我想要这样的东西返回(在此示例中:)]
['g', 'd', 'a', 'h', 'e', 'b', 'i', 'f', 'c']
我已经读过https://docs.sympy.org/latest/modules/combinatorics/permutations.html,但不知道如何。
关于任何可能的解决方法的任何建议?
Sympy noob想知道如何使Sympy Permutation应用于列表。例如,从sympy.combinatorics导入置换lst = ['a','b','c','d','e','f','g','h','i'] perm =置换([[[0,...
您可以只执行perm(lst)