Python3 適合初學者學習的銀行賬戶登錄系統(tǒng)實例
更新時間:2017年08月08日 09:02:14 投稿:jingxian
下面小編就為大家?guī)硪黄狿ython3 適合初學者學習的銀行賬戶登錄系統(tǒng)實例。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
一、所用知識點:
1. for循環(huán)與if判斷的結合
2. %s占位符的使用
3. 輔助標志的使用(標志位)
4. break的使用
二、代碼示例:
''' 銀行登錄系統(tǒng) ''' uname = "bob" passwd = 123 judgment = 0 choice = 2 for i in range(3): username = input("請輸入用戶名:") password = int(input("請輸入密碼:")) if username == uname and password == passwd: #用戶名和密碼必須同時成立 print("~~~歡迎%s使用銀行自助服務系統(tǒng)~~~" %uname) # %s是占位符 judgment = 1 break else: if choice != 0: print("?。?!登陸失?。。?!" + "您還有" + str(choice) + "次機會") else: print("!?。〉顷懯。。。?) choice = choice - 1 if judgment == 0: print("三次機會已用完,此卡將凍結10分鐘") #只是提示信息,凍結操作并未編寫 # 第二種思路 # uname = "bob" # passwd = 123 # # choice = 2 # # for i in range(3): # username = input("請輸入用戶名:") # password = int(input("請輸入密碼:")) # if username == uname and password == passwd: # print("~~~歡迎%s使用銀行自助服務系統(tǒng)~~~" %uname) # %s是占位符 # # break # else: # if choice != 0: # print("?。?!登陸失敗?。?!" + "您還有" + str(choice) + "次機會") # else: # print("!?。〉顷懯。。。?) # choice = choice - 1 # else: # print("三次機會已用完,此卡將凍結10分鐘") # #
以上這篇Python3 適合初學者學習的銀行賬戶登錄系統(tǒng)實例就是小編分享給大家的全部內容了,希望能給大家一個參考,也希望大家多多支持腳本之家。
相關文章
Python自動采集微信聯(lián)系人的實現(xiàn)示例
這篇文章主要介紹了Python自動采集微信聯(lián)系人的實現(xiàn)示例,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧2020-02-02如何修復使用 Python ORM 工具 SQLAlchemy 時的常見陷阱
SQLAlchemy 是一個 Python ORM 工具包,它提供使用 Python 訪問 SQL 數(shù)據(jù)庫的功能。這篇文章主要介紹了如何修復使用 Python ORM 工具 SQLAlchemy 時的常見陷阱,需要的朋友可以參考下2019-11-11