我如何使我的代码写入CSV并添加新用户

时间:2019-04-30 13:37:44

标签: python csv file-writing

因此,我的A级课程作业将于明天到期,我决定昨天重新开始(愚蠢的ik)。我正在为Dijkstra做基础教育者,但首先我想添加一个登录系统。如果我打开csv并将用户名,密码和功能直接写入其中,则我有一个工作系统。我只需要弄清楚如何在程序中添加新帐户的能力,因为我已经可以读取csv并检索信息了。任何想法表示赞赏:)。

我从
开始 def new_user(self):

newuser = self.logbtn.get()== 1

但是我不知道从那里去哪里:/

class LoginFrame(Frame):
    def __init__(self, master):
        super().__init__(master)

        self.label_username = Label(self, text="Username")
        self.label_password = Label(self, text="Password")

        self.entry_username = Entry(self)
        self.entry_password = Entry(self, show="*")

        self.label_username.grid(row=0, sticky=E)
        self.label_password.grid(row=1, sticky=E)
        self.entry_username.grid(row=0, column=1)
        self.entry_password.grid(row=1, column=1)

        self.checkbox = Checkbutton(self, text="New Account")
        self.checkbox.grid(columnspan=2)

        self.logbtn = Button(self, text="Login", command=self.login)
        self.logbtn.grid(columnspan=2)

        self.pack()


the 'self.checkbox' part is what i want to tick when creating a new user,
which will take the username and password, write it to the csv with the option
to choose 'student' or 'teacher'and add it to the end of existing users however making a new function is pointless
as i dont know how to write to a csv.

0 个答案:

没有答案