0
我試圖用python創建一個.csv文件。 .csv文件已成功創建,但它在輸入以下結果的條目之間跳過一行。Python - CSV模塊,跳過行
['Name', 'Profession']
[]
['Derek', 'Software Developer']
[]
['Steve', 'Software Developer']
[]
['Paul', 'Manager']
[]
任何幫助解決這個問題將不勝感激。
import csv
with open('persons.csv', 'w') as csvfile:
filewriter = csv.writer(csvfile, delimiter=',',
quotechar='|', quoting=csv.QUOTE_MINIMAL)
filewriter.writerow(['Name', 'Profession'])
filewriter.writerow(['Derek', 'Software Developer'])
filewriter.writerow(['Steve', 'Software Developer'])
filewriter.writerow(['Paul', 'Manager'])
with open('persons.csv', 'rt') as f:
reader = csv.reader(f)
# read file row by row
for row in reader:
print(row)
檢查這個答案:https://stackoverflow.com/questions/3348460/CSV文件寫入與 - 蟒-具有空白線之間 - 的每行 –