Python Write registration program

Source: Internet
Author: User

# 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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.