<p>这是我的密码:</p>
<pre><code> eeee = input('\nWhat do you want to combine each other with? ')
first = []
second = []
with open('First.txt', 'r') as f:
for line in f.readlines():
first.append(line)
with open('Second.txt', 'r') as f:
for line in f.readlines():
second.append(line)
with open('NewStuff.txt', 'a') as f:
for thing in first:
for thing2 in second:
f.write(thing + str(eeee) + thing2)
</code></pre>
<P>我想从FILE1获得第一行,在中间添加一些东西(不管EEEE被输入什么),然后从FILE2打印第一行,然后得到第二行,重复</p>
<p>因为您希望<code>str(eeee)</code>中的所有字符串都是<code>second</code>,所以您可以将它添加到该列表所有项目的开头</p>
<pre class="lang-py prettyprint-override"><code>third = [str(eeee)+i for i in second]
</code></pre>