擅长:python、mysql、java
<p>我不认为你需要使用列表或附加到文件。你知道吗</p>
<p>你在找这样的东西。你知道吗</p>
<pre><code>def create_lined_ver(filename):
with open(filename + ".txt") as f_in, open(filename + " _lined.txt", "w") as f_out:
for num, line in enumerate(f_in):
f_out.write("[{}]: {}\n".format(num, line))
</code></pre>