我正在尝试创建一个值列表,以后可以稍后阅读,排序和搜索它们。虽然当我写入我的csv文件时,它会跳过第一行并在下一行打印。
我内心和外部都在寻找解决方案,但没有任何帮助。
这是我的代码:
from tkinter import *
import csv
window=Tk()
def show_entry_fields():
with open('shoplist.csv', 'a') as csvfile:
list = csv.writer(csvfile, delimiter=',', lineterminator='\n')
list.writerow([ "%s" % (e3.get()) "%s" % (e4.get()), "%s" % (e5.get())])
Button(window, text='Add', command=show_entry_fields).grid(row=3, column=3)
v = StringVar()
e3 = Entry(window)
e4 = Entry(window)
e5 = Entry(window)
e3.grid(row = 3, column = 1)
e4.grid(row = 4, column = 1)
e5.grid(row = 5, column = 1)
l3 = Label(window, text = "Name:")
l3.grid(row = 3, column = 0)
l4 = Label(window, text = "Location:")
l4.grid(row = 4, column = 0)
l5 = Label(window, text = "Rate /5:")
l5.grid(row = 5, column = 0)