Python模擬賬號建立以及登陸

2021-09-09 06:33:21 字數 1284 閱讀 6029

先給出如下所示**:

db={}

def newuser():

prompt='login desired:'

while true:

name=input(prompt)

if name in db:

prompt='name taken,try another:'

continue

else:

break

pwd=input('password:')

db[name]=pwd

def olduser():

name=input('login:')

pwd=input('password:')

password=db.get(name)

if password==pwd:

print('###password confirmed. hi! '+name)

else:

print('###wrong prassword.')

def showmenu():

prompt='''

(n)ew user login

(e)xisting user login

(q)uit

enter choice:'''

done=false

while not done:

chosen=false

while not chosen:

try:

choice=input(prompt).strip()[0].lower()

except(eoferror,keyboardinterrupt):

choice='q'

print('\nyou picked:[%s]' %choice)

if choice not in'neq':

print('###invalid option,try again')

else:

chosen=true

if choice=='q':done=true

if choice=='n':newuser()

if choice=='e':olduser()

if __name__=='__main__':

showmenu()

只是乙個小練習,不難理解。這回用的是if語句來控制函式的選擇,而不是用之前的cmds,鍵值對的那種。

最後print語句還是有點不習慣,中覺得python3怪怪的,,,,%choice要放在括號裡,而不是外面。。。

python3 selenium進行模擬登陸

這裡主要就說下,當表籤中只有class,而且class是這種形式的 class 的名字是自定義的,內容優勢有空格的形式,我們使用常規的定位方法總是出現問題,提示找不到元素。解決上面的辦法就是 brows.find element by css selector data test class kw ...

Mysql建立子賬號以及許可權設定

命令 建立乙個使用者名為test,密碼為123456的子賬號。命令 create user test localhost identified by 123456 這種建立方式只能本地登入 create user test identified by 123456 這種建立方式可以遠端登入,即別的地...

mysql8 建立使用者賬號以及賦予使用者許可權

建立使用者並設定密碼 123456 是密碼 create user test localhost identified by 123456 create user test identified by 123456 其中localhost指本地才可連線 可以將其換成 指任意ip都能連線 也可以指定i...