擅长:python、mysql、java
<p>您可以使用<a href="https://www.w3schools.com/python/ref_func_zip.asp" rel="nofollow noreferrer">^{<cd1>}</a>和<a href="https://kite.com/python/answers/how-to-open-multiple-files-using-with-in-python#:%7E:text=Use%20open()%20to%20open,files%20at%20the%20same%20time." rel="nofollow noreferrer">openning multiple files</a>尝试类似的方法:</p>
<pre><code>eeee = input('\nWhat do you want to combine each other with? ')
with open('First.txt', 'r') as f1, open('Second.txt', 'r') as f2,open('NewStuff.txt', 'a') as fnew:
for first, second in zip(f1.readlines(),f2.readlines())
fnew.write(first.replace('\n','')+' '+ str(eeee)+' '+ second)
</code></pre>