考虑以下两行代码:
对于t
字典,t = {1: (1, 0, 0, 0, 0, 0, 0, 0, 0), 2: (1, 1, 1, 1, 1, 1, 1, 1, 0)}
,当我尝试做:list(t[1])
将 转换tuple
为 alist
时,它给了我输出[(0,1)]
。但是当我这样做时list(1,0,0,0)
,它给了我(它应该)[1,0,0,0]
。这里出了什么问题?
整个成绩单
# given a prime p, return all A_n representations of dimension = p^2
def rankrep(p):
bound = p*p
s = SymmetricFunctions(QQ).schur()
Sym_p = s[p]
A = lambda i: WeylCharacterRing("A{0}".format(i))
deg = []
index = []
L = []
for i in xrange(bound):
deg.append([])
fw = A(i+1).fundamental_weights()
temp = A(i+1)
for j in fw.keys():
deg[i].append(temp(fw[j]).degree())
if temp(fw[j]).degree() == bound:
index.append('A'+str(i+1)+'(fw['+str(j)+'])')
L.append(fw[j])
return index, deg, L
def make_vars2(L):
return dict(enumerate(L, start=1))
[index, deg, L] = rankrep(3)
t = make_vars2(L)
print(t[1])
print t
list(t[1])
给我
(1, 0, 0, 0, 0, 0, 0, 0, 0)
{1: (1, 0, 0, 0, 0, 0, 0, 0, 0), 2: (1, 1, 1, 1, 1, 1, 1, 1, 0)}
[(0, 1)]