擅长:python、mysql、java
<p>把你的问题陈述:</p>
<blockquote>
<p>trying to write a piece of code that, from an opened txt document, will print out the line number that each piece of information is on</p>
</blockquote>
<p>正如@roganjosh试图解释的那样,您错误地使用了<code>enumerate</code>:</p>
<pre><code>with open("data.txt") as my_document:
for i, data in enumerate(my_document):
print(i, data)
</code></pre>