1. python程序編寫登錄程序
count = 0
while count<3:
name = input('請輸入賬號:')
password = input('請輸入密碼:')
if not name or not password:
print('賬號密碼不能為空')
right_name = 'admin'
right_password = '123xyz'
if name == right_name:
if password == right_password:
print('歡迎{}登錄'.format(name))
break
else:
print('用戶名密碼錯誤')
else:
print('用戶名密碼錯誤')
count += 1
2. python作業:1.設計賬號登錄程序,要求如下:(1)動態獲取用戶名和密碼,格式為"用戶名:密碼"
這個需求沒說清楚用什麼平台,比如是桌面版,還是web版。對所用技術或者庫有沒有什麼限制。
3. 怎麼用Python寫一個授權的小程序,輸入用戶名和密碼後可登陸
import MySQLdb conn=MySQLdb.connect(user='root',passwd='pwd',host='127.0.0.1',db='python_test') cur=conn.cursor() cur.execute("select * from users where uid='101' and login='ong'") ##uid
4. 用python寫程序,用戶名為:1密碼為:123456讓程序一直執行,直到輸正確,顯示『歡迎回來』
name=input('請輸入用戶名:')
whileTrue:
#name=input('請輸入用戶名:')
ifname=='1':
whileTrue:
try:
powerword=eval(input('請輸入密碼:'))
ifpowerword==123456:
name=100
break
else:
print('密碼不正確,請重新輸入:')
except:
print('密碼不正確,請重新輸入:')
elifname==100:
break
else:
print('用戶名不正確,請重新輸入:')
name=input('請輸入用戶名:')
print('歡迎回來')
5. python利用提供的用戶名和密碼編寫程序自動登錄指定網站代碼是怎麼樣
你要抓包,看那個網站提交的方式,和參數,然後在你的代碼裡面添加變數,在訪問請求裡面將用戶名和密碼添加,然後提交就行了
6. 如何使用python語言實現用戶登錄系統
1、使用python3執行程序。按提示輸入1或2,登錄或退出程序
2、輸入用戶名後,如果用戶名被鎖定及無效用戶名,程序會退出,請確保輸入正確。
3、輸入用戶名正確後,輸入密碼。用戶名正確的情況下,密碼連續輸錯三次,用戶將被鎖定,禁止登錄系統
7. 使用python做登陸程序,在資料庫中查找用戶名和密碼是否正確
import MySQLdb
conn=MySQLdb.connect(user='root',passwd='pwd',host='127.0.0.1',db='python_test')
cur=conn.cursor()
cur.execute("select * from users where uid='101' and login='ong'")
##uid 是你的密碼 ;login是你的用戶名
num=0
for data in cur.fetchall():
num=num+1
print data
if(num != 0):
print '登陸成功'
else:
print '用戶名或密碼未找到'
cur.close()
conn.commit()
conn.close()
如果還有其他問題可以再問
8. python簡單程序設計:許多計算機程序系統都需要登錄,且要求賬號密碼輸入錯誤不得超過三次
##注意:最左邊每個=表示一個空格
##修改成你的姓名
name="aabb"
c,userinfo=0,{"account":"123","password":"456","count":3}
t=input("請輸入賬號:")
while t!=userinfo["account"] and c<=userinfo["count"]:
====c=c+1
====t=input("賬號錯誤,請重新輸入:")
if c<=userinfo["count"]:
====t=input("請輸入密碼:")
====while t!=userinfo["password"] and c<=userinfo["count"]:
========t=input("密碼錯誤,請重新輸入:")
========c=c+1
if c<=userinfo["count"]:
====print("歡迎%s登錄到本系統!" %name)
else:
====print("你登錄次數過多。%s,請聯系管理員。" %name)
9. 怎麼在python設置用密碼登錄
用字典比用list 好些
list_user={}
cmd=raw_input('輸入命令 1 注冊 2登錄 3 退出:')
##print 'cmd:',cmd,cmd <>3,type(cmd)
cmd = int(cmd)
while (cmd <>3):
10. Python設計一個用戶名和密碼
name=input()
if name=='這個地方是你判斷用的用戶名':
縮進pass=input()
縮進if pass=='這里是你判斷的密碼':
縮進縮進print('用戶名密碼都對')
縮進else:
縮進縮進print('密碼不對')
else:
縮進print('用戶名不對')