擅长:python、mysql、java
<p>在这样的文件中迭代行时,行仍将包含最后的换行符<code>'\n'</code>(如果后面没有空行,则最后一行除外)。最简单的方法就是脱掉它们:</p>
<pre><code>for line in inputFile:
ProcessID(line.strip())
# OR: if you want to be more explicit and keep all other white space
ProcessID(line.rstrip('\n'))
</code></pre>