有没有办法将以下行包含为地图?
alist = []
for name in range(4):
for sname in range(15):
final = Do_Class(name, sname) #Is a class not to be bothered with
alist.append(final)
而是作为 alist.append(map(..... 内可能有多个地图?))
更新:
x = [Do_Class(name, sname) for name in xrange(15) for sname in xrange(4)]
alist = [i for i in x]
以上工作没有错误
alist = [i for i in Do_Class(name, sname) for name in xrange(15) for sname in xrange(4)]
抛出 UnboundLocalError:赋值前引用的局部变量 'sname'
这一定是 Python 中最蹩脚的东西