# Demand Analysis
# 1. Write a registered program, enter username, password, password confirmation, enter the account number and password can not be empty,
# 2. Two times the password must be the same, the user name can not be duplicated, the number of errors is 3 times
#分析
# 1. Enter username, password, password confirmation
# username
# passwd
# C_PASSWD
# 2. Enter the account number and password cannot be empty
#3. Two input passwords must be the same
#4. User names cannot be duplicated
# need to get the files that store user information and make a comparison (new knowledge points) and store the registered user information in the user Information Store file.
The slash in the #python is the opposite of the slash in Windows
#5. The number of errors is 3 times (complete)
I=0
While True:
File = open (' C:/username.txt ', ' A + ')
File.seek (0)
Users = []
For line in file:
Username = Line.strip ()
Users.append (username)
Username = input (' Please enter user name: ')
passwd = input (' Please enter password: ')
C_PASSWD = input (' Please enter password again: ')
If username = = ' or passwd = = ' or c_passwd = = ':
Print ("User name or password cannot be empty or re-confirm password cannot be empty")
Elif c_passwd! = passwd:
I+=1
Print (' Password and Confirm password inconsistent ')
If i==3:
Break
Elif Username in Users:
Print (' User name already exists ')
Else
Print (' Congratulations, registration successful! ‘)
File.write (username+ ' \ n ')
File.close ()
Python Write registration program