欧美一区二区三区老妇人-欧美做爰猛烈大尺度电-99久久夜色精品国产亚洲a-亚洲福利视频一区二区

python和sqlite3數(shù)據(jù)庫如何實(shí)現(xiàn)簡單登陸注冊功能-創(chuàng)新互聯(lián)

這篇文章將為大家詳細(xì)講解有關(guān)python和sqlite3數(shù)據(jù)庫如何實(shí)現(xiàn)簡單登陸注冊功能,文章內(nèi)容質(zhì)量較高,因此小編分享給大家做個(gè)參考,希望大家閱讀完這篇文章后對相關(guān)知識有一定的了解。

10年積累的成都做網(wǎng)站、成都網(wǎng)站設(shè)計(jì)、成都外貿(mào)網(wǎng)站建設(shè)經(jīng)驗(yàn),可以快速應(yīng)對客戶對網(wǎng)站的新想法和需求。提供各種問題對應(yīng)的解決方案。讓選擇我們的客戶得到更好、更有力的網(wǎng)絡(luò)服務(wù)。我雖然不認(rèn)識你,你也不認(rèn)識我。但先建設(shè)網(wǎng)站后付款的網(wǎng)站建設(shè)流程,更有博樂免費(fèi)網(wǎng)站建設(shè)讓你可以放心的選擇與我們合作。
#coding=utf8
#登錄注冊功能齊了
import wx
import sqlite3
class MyFrame(wx.Frame):

    def __init__(self):
        wx.Frame.__init__(self, None, -1, 'DB EXAMPLE',pos=wx.DefaultPosition,size=(300, 150))
        panel = wx.Panel(self, -1) 
        
        usernameLabel = wx.StaticText(panel, -1, "用戶名:")#設(shè)置用戶名Label
        self.usernameText = wx.TextCtrl(panel, -1, "",size=(175, -1))#設(shè)置輸入用戶名的文本框
        self.usernameText.SetInsertionPoint(0)
        
        
        pwdLabel = wx.StaticText(panel, -1, "密碼:")#設(shè)置密碼的Label
        self.pwdText = wx.TextCtrl(panel, -1, "", size=(175, -1),style=wx.TE_PASSWORD)#設(shè)置密碼的文本框
        
        
        loginButton=wx.Button(panel,-1,"登錄")#登錄按鈕
        exitButton=wx.Button(panel,-1,"退出")#退出按鈕
        registerButton=wx.Button(panel,-1,"注冊")
        
        sizer = wx.FlexGridSizer(cols=2, hgap=6, vgap=6)#sizer設(shè)置
        sizer.AddMany([usernameLabel, self.usernameText, pwdLabel, self.pwdText,loginButton,exitButton,registerButton])#把它們都安在sizer里
        panel.SetSizer(sizer)
        
        self.Bind(wx.EVT_BUTTON, self.OnLogIn, loginButton)#登錄按鈕綁定事件
        self.Bind(wx.EVT_BUTTON, self.OnCloseWindow, exitButton)#退出按鈕綁定事件
        self.Bind(wx.EVT_BUTTON, self.OnRegister, registerButton)#注冊按鈕綁定事件
        
        
        
        
#         self.buildingDB()#創(chuàng)建數(shù)據(jù)庫和表,此語句只運(yùn)行第一次,之后將其注釋掉
        
    def OnLogIn(self,event):#登錄方法
        self.username=self.usernameText.GetValue()
        self.password=self.pwdText.GetValue()
        username=str(self.username.strip())
        conn=sqlite3.connect('db01')
        cur=conn.cursor()
        cur.execute("SELECT password FROM table01 WHERE username='%s'"% username)
        t=cur.fetchone()[0]
        print t
        if str(self.password)==str(t):
            print 'Password is correct!'
            self.Maximize(True)#窗口較大化,意思意思主界面
        else:
            print 'failed'
    def OnCloseWindow(self,event):#關(guān)閉窗口
        self.Close()
        
#     def loginmethod(self):
#         
#         pass
    
    def buildingDB(self):#建立數(shù)據(jù)庫
        conn=sqlite3.connect("db01")
        cur=conn.cursor()
        cur.execute("""
        CREATE TABLE table01(username text,password text, realname text,account text,workingdept text,phonenumber text)
        """)
        cur.execute("""INSERT INTO table01 values('zhangsan','123','zhangsan','','','')""")
        cur.execute("""INSERT INTO table01 values('lisi','123','zhangsan','','','')""")
        cur.execute("""INSERT INTO table01 values('wangwu','123','zhangsan','','','')""")
        conn.commit()
        cur.execute("""SELECT username FROM table01 WHERE username='zhangsan'""")
#         p=cur.fetchone()
#         print p
        cur.close()
         
    def OnRegister(self,event):#注冊方法
        self.username=self.usernameText.GetValue()
        self.password=self.pwdText.GetValue()
        conn=sqlite3.connect("db01")
        cur=conn.cursor()
        cur.execute("INSERT INTO table01 VALUES('%s','%s','','','','')"%(self.username,self.password))
        conn.commit()
        print "Registered successfully!"
        cur.close()
        
if __name__ == '__main__':
    app = wx.PySimpleApp()
    frame = MyFrame()
    frame.Show()
    app.MainLoop()

關(guān)于python和sqlite3數(shù)據(jù)庫如何實(shí)現(xiàn)簡單登陸注冊功能就分享到這里了,希望以上內(nèi)容可以對大家有一定的幫助,可以學(xué)到更多知識。如果覺得文章不錯(cuò),可以把它分享出去讓更多的人看到。

網(wǎng)站欄目:python和sqlite3數(shù)據(jù)庫如何實(shí)現(xiàn)簡單登陸注冊功能-創(chuàng)新互聯(lián)
文章地址:http://chinadenli.net/article12/eopdc.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供微信小程序網(wǎng)站建設(shè)動(dòng)態(tài)網(wǎng)站網(wǎng)站導(dǎo)航響應(yīng)式網(wǎng)站面包屑導(dǎo)航

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

微信小程序開發(fā)