我想写超过21个列表包含相同数量的项目文本文件中的列。太多的静态嵌套块python
import random
a=[]
b=[]
....
q=[]
for i in range(200):
a.append(random.gauss(10,0.1))
b.append(random(20,0.5))
....
q.append(random.gauss(50,0.2)
for aVal in a:
for bVal in b:
....
for qVal in q:
print(aVal, "\t ", bVal, ", ", .... , qVal)
....
SystemError: too many statically nested blocks
如何将每个列表写入文本文件中的列?例如
0.892550 0.872493 0.206032 2.528080
0.722350 0.303438 0.176304 2.436103
0.875931 0.717765 0.144785 2.583095
0.890831 0.411748 0.124370 2.540974
0.764183 0.728080 0.128309 2.506590
0.831232 0.545845 0.130100 2.517765
0.754441 0.826074 0.208539 2.604585
0.707450 0.367049 0.198868 2.503152
0.736103 0.554441 0.097865 2.563324
0.792837 0.808883 0.179527 2.526361
0.719484 0.690258 0.215344 2.643266
0.788252 0.824355 0.189198 2.455874
程度的嵌套究竟什么是你的目标?我不确定你用上面的代码得到什么。 – CoryKramer 2014-10-20 16:36:04
你在做什么? '随机(10:1)'?你应该看看['itertools.product'](https://docs.python.org/2/library/itertools.html#itertools.product)(也许在你去那里时阅读'random'文档...) – jonrsharpe 2014-10-20 16:36:09
您有问题吗? – 2014-10-20 16:36:21