擅长:python、mysql、java
<p>除非我漏掉了什么,否则像这样的东西应该是你想要的?如果您使用numpy数组,只需在使用之前将它们转换为一个multidim列表(如下所示),您就可以开始了。你知道吗</p>
<pre><code>filename = "name" # logfile
fittings = [range(8) for fit in range(5)] # example data matrix
with open(filename,'w') as f:
for fit in fittings:
fit.insert(0,"filexy") # the filename at the beginning of the line
f.write(str(fit)[1:-1]+"\n") # write list, ignore brackets
</code></pre>
<p>生成包含以下内容的文件“name”:</p>
<pre><code>'filexy', 0, 1, 2, 3, 4, 5, 6, 7
'filexy', 0, 1, 2, 3, 4, 5, 6, 7
'filexy', 0, 1, 2, 3, 4, 5, 6, 7
'filexy', 0, 1, 2, 3, 4, 5, 6, 7
'filexy', 0, 1, 2, 3, 4, 5, 6, 7
</code></pre>