Park landing simulation blog!

One. First, the program starts, displays the following contents for users to choose:

1. Log

2. Register

3. Go to the article page

4. Enter comments page

5. Go to diary page

6. Go to collection page

7. cancellation of account

8. Quit the entire program

two. Function must be implemented:

1. Registration functional requirements:

a. a user name and password to be recorded in the file.

. B User Requirements: You can only contain letters or numbers can not contain special characters and ensure that the user name is unique.

. C password requirements: a length between 6 to 14 characters.

d. Log has not been more than three times successfully, quit the whole program.

2. Log on functional requirements:

a. a user to enter a user name and password to login authentication.

. B After a successful login, you can only access 3--7 options, visit 3:00 If you do not log on or log unsuccessful --7 option does not allow access to jump to login. (Modify global variables)

3. Go to the requirements of the article page:

Welcome prompted to enter the article page xx. (Xx is the user name currently logged in)

4. Enter comments page request:

Welcome page xx prompted to enter a comment.

5. Requirements to enter the diary page:

Welcome prompted to enter the diary page xx.

6. Go to page collection requirements:

Welcome page xx prompted to enter the collection.

7. cancellation account requirements:

Not quit the whole program, but the state has logged into the unregistered status (need to log in again to access the options of 3 to 7).

8. Quit the entire program requirements:

It is the end of the process.

4. Use the code to achieve three user login and locking (elected to do, plenty of time to make a recommendation to do)

Project Analysis:

A first program starts, it displays the following contents for users to choose:

1. Registration

2. Log

a. When the user selects a login, first determine the user name exists not exist can not be registered in userinfo.txt table

b. When the registered user name does not exist in the user name and password is written to the file userinfo.txt

Consistent with c. Select the user login when the judgment entered by the user account and password are stored userinfo.txt

d. the same user name and password on the termination of the cycle, and prompts the user to log on success!

e. a user name and password are inconsistent, and only three times the opportunity to log on, the user is prompted three times after the name is locked, contact the administrator! and terminate the loop

f. When the user name output three times, the account running the program again. login lockout continues to prompt the user name is locked, contact the administrator!

d. Log has not been more than three times successfully, quit the whole program.

2. Log on functional requirements:

a. a user to enter a user name and password to login authentication.

. B After a successful login, you can only access 3--7 options, visit 3:00 If you do not log on or log unsuccessful --7 option does not allow access to jump to login. (Modify global variables)

name, pwd, In Flag = [], [], []
DEF FUNC ():
with Open ( "userinfo.txt.txt", "W") AS F:
for I in Range (len (name)):
F. Write (name [I] + ":" + pwd [I] + ":" + In Flag [I] + '\ n-')
LST1 = "" "
1. login
2. Register
8. quit the entire program
" " "
lst2 =" ""
3. enter the article page
4. enter comments page
5. Go to diary page
6. Go to favorites page
7. cancellation of the account
8. quit the whole program
. "" "

k = ""
Flag = False
with open("userinfo.txt.txt") as f:
for i in f.readlines():
if len(i)>0:
a, b, c = i.split(":")
name.append(a)
pwd.append(b)
flag.append(c.strip("\n"))
while 1:
while Flag:
print(lst2)
break
else:
print(lst1)
num = input("请输入序号")
if num == "1":
count = 3
name = input("请输入账号:")
while count > 0:
if name in name:
if flag[name.index(_name)] == "1":
pwd = input("请输入密码")
if pwd == pwd[name.index(_name)]:
print("登陆成功!")
Flag = True
k = name
BREAK
the else:
Print ( "Wrong password")
COUNT - = 1
the else:
Print ( "user name is locked, contact the administrator")
BREAK
the else:
Print ( "Username does not exist")
BREAK
the else:
Flag [name.index (_name)] = "0"
Print ( "user name is locked, contact the administrator")
elif NUM == "2":
the while 1:
name
= the iNPUT ( "Please enter your user name:")
IF name
.isalnum ( ):
pwd
= the iNPUT ( "Please enter your password:")
IF 16> len (pwd
)> 5:
IF name
not in name:
name.append (name_)
pwd.append (pwd_)
flag.append ( "1")
Print ( "registration success")
BREAK
the else:
print ( "existing user name, please re-enter")
the else:
print ( "length should be between 6 to 14 characters")
the else:
print ( "illegal user name")

elif num == "3" and Flag:
    print(f"欢迎{k}进入文章页面")
elif num == "4" and Flag:
    print(f"欢迎{k}进入评论页面")
elif num == "5" and Flag:
    print(f"欢迎{k}进入日记页面")
elif num == "6" and Flag:
    print(f"欢迎{k}进入收藏页面")
elif num=='7'and Flag:
    func()
    Flag = False
    print("注销成功")
elif num == "8":
    func()
    print("退出成功")
    exit()
else:
    print("未登陆或字符错误")

Guess you like

Origin www.cnblogs.com/sjf981012-/p/11223174.html