擅长:python、mysql、java
<p>你可以试试这个主意:</p>
<p>首先,将两个列表写入两列文本文件。</p>
<pre><code>a=[0.2342,2.0002,0.1901]
b=[0.4245,0.5123,6.1002]
c = [a, b]
with open("list1.txt", "w") as file:
for x in zip(*c):
file.write("{0}\t{1}\n".format(*x))
</code></pre>
<p>其次,重新打开保存的文件<code>list1.txt</code></p>
<pre><code>with open("list1.txt", "r+") as file:
d = file.readlines()
</code></pre>
<p>第三,添加额外数据</p>
<pre><code>e=[1.2300,0.0002,2.0011]
f=[0.4000,1.1004,0.9802]
g = [e, f]
h = []
for i in d:
h.append(i)
for x in zip(*g):
h.append("{0}\t{1}\n".format(*x))
</code></pre>
<p>第四,保存文本文件</p>
<pre><code>with open("list2.txt", "w") as file1:
for x in h:
file1.writelines(x)
</code></pre>
<p><code>list2.txt</code>文件中的输出如下</p>
<pre><code>0.2342 0.4245
2.0002 0.5123
0.1901 6.1002
1.23 0.4
0.0002 1.1004
2.0011 0.9802
</code></pre>