擅长:python、mysql、java
<p>您可以使用<code>os.path.getsize(filename)</code>获取目标文件的大小。然后,当您从文件中读取数据时,可以使用一个简单的公式计算进度百分比
<code>currentBytesRead/filesize*100%</code>。这个计算可以在每N行的末尾进行。</p>
<p>对于实际进度条,请查看<a href="https://stackoverflow.com/questions/3173320/text-progress-bar-in-the-console">Text Progress Bar in the Console</a></p>