擅长:python、mysql、java
<p>我就是这样做的:</p>
<pre><code> with open(txtfile, 'r') as infile, open(csvfile, 'w') as outfile:
stripped = (line.strip() for line in infile)
lines = (line.split(",") for line in stripped if line)
writer = csv.writer(outfile)
writer.writerows(lines)
</code></pre>
<p>希望有帮助!</p>