Home > Backend Development > Python Tutorial > Python3 implements a simple bank account login system example

Python3 implements a simple bank account login system example

黄舟
Release: 2017-08-08 11:31:21
Original
3805 people have browsed it

The following editor will bring you an example of a Python3 bank account login system suitable for beginners to learn. The editor thinks it’s pretty good, so I’ll share it with you now and give it as a reference. Let’s follow the editor and take a look.

1. Knowledge points used:

1. The combination of for loop and if judgment

2. Use of %s placeholder

3. Use of auxiliary flags (flags)

4. Use of break

2. Code example:


'''
银行登录系统
'''

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使用银行自助服务系统~~~" %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使用银行自助服务系统~~~" %uname) # %s是占位符
#
#   break
#  else:
#   if choice != 0:
#    print("!!!登陆失败!!!" + "您还有" + str(choice) + "次机会")
#   else:
#    print("!!!登陆失败!!!")
#   choice = choice - 1
# else:
#  print("三次机会已用完,此卡将冻结10分钟")
# 
#
Copy after login

The above is the detailed content of Python3 implements a simple bank account login system example. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template