【发布时间】:2019-12-13 16:36:51
【问题描述】:
如何让 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,但不知道如何阅读。
有什么建议可以解决这个问题吗?
【问题讨论】:
标签: python python-3.x list permutation sympy