登录操作(方法一:设置flag标志位)

Posted startl

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了登录操作(方法一:设置flag标志位)相关的知识,希望对你有一定的参考价值。

登录操作(方法一:设置flag标志位)

user_name="star"
passwoed=‘123‘
passed_authentication=False
count=0
for i in range(3):
u_username=input("please input your username:")
u_password=input("please input your password:")

if u_username==user_name and u_password==passwoed:
print("welcome to %s"%u_username)
passed_authentication=True
break
else:
count+=1
print("your username or password is Error")
if not passed_authentication:
count==3
print("you have try more times,would you want to try again? please input yes or no,please choose")
answer=input("your choose:")
if answer==‘yes‘:
print("go away,hahahah")

Input:正确操作

please input your username:qwe
please input your password:222
your username or password is Error
please input your username:star
please input your password:123
welcome to star

进程已结束,退出代码0

Input:错误操作

please input your username:aa
please input your password:aa
your username or password is Error
please input your username:aa
please input your password:aa
your username or password is Error
please input your username:aa
please input your password:aa
your username or password is Error
you have try more times,would you want to try again? please input yes or no,please choose
your choose:yes
go away,hahahah

进程已结束,退出代码0

以上是关于登录操作(方法一:设置flag标志位)的主要内容,如果未能解决你的问题,请参考以下文章

python线程的同步事件Event

ceph flag 设置#yyds干货盘点#

python3.5中的标志位

PY3_线程红绿灯

Jvm(36),class文件结构----访问标志

flag+文件操作