我想制作一个列表框来列出用户.conf文本文件。你知道吗
如何列出它来选择要删除的帐户?你知道吗
81045用户密码==“81045”
列表框中的首选输出:
81045个
def deleteuser():
with open('C:/FreeRADIUS.net/etc/raddb/users.conf', "r") as fh:
lines = fh.readlines()
with open('C:/FreeRADIUS.net/etc/raddb/users.conf', "w") as fh:
for line in lines:
if deleteuserentry.get() in line and deleteuserpwd.get() == "Pa$$w0rd123" :
tkMessageBox.showinfo("success", "Account Deleted")
end()
deleteteuser = ttk.Label(page1, text="Delete User").grid(column=0, row=6, sticky='W')
deleteusername = ttk.Label(page1, text="Enter current user's username:").grid(column=0, row=7, sticky='W')
deleteuserentry = ttk.Listbox(page1, selectmode = BROWSE)
deleteuserentry.grid(row=7, column=1, columnspan=2)
for lines in ('C:/FreeRADIUS.net/etc/raddb/users.conf', "r"):
lb.insert(END,line)
deleteuserpassword = ttk.Label(page1, text="Enter Administrator's password:").grid(column=0, row=8, sticky='W')
deleteuserpwd = ttk.Entry(page1, show='*')
deleteuserpwd.grid(row=8, column=1, columnspan=2)
deleteuserconfirm = Button(page1, text='Delete this User', borderwidth=2, command= deleteuser)
deleteuserconfirm.grid(row=9, column=0, sticky='W')
du = Button(page1, text='import file to delete multiple accounts', borderwidth=2, command= du)
du.grid(row=9, column=2, sticky='E')
您可以通过regex匹配行,在开始处选择用户id,并将行数据填充到一个列表中。当从列表框中删除一个项目时,用户id将附加到另一个列表中。当接口关闭时,会发生从文件中删除的实际操作。这是我的意思的结构。你可以用它作为一个例子-在需要的地方进行优化。你知道吗
相关问题 更多 >
编程相关推荐