1.python Language Implementation User Login program

Source: Internet
Author: User

 #!/usr/bin/env python 
#-*-coding:utf-8-*-
Count = 0
Flag = 0
#提示用户需要做什么操作
option = Int (Input (" Hint: The number 1 is the registered user, the number 2 is the login system, select: "))

If option = 1:
user = input (" Please enter user name: ")
passwd = input (" Please enter password: ")
f = open ("User.txt", "a")
F.write ("%s:%s\n"% (user,passwd))
F.close ()
elif option = = 2:
While Coun T < 3:
user = input ("Enter login name:")
passwd = input ("Please enter password:")
Userpasslist = [I.strip () for I in open (' User.txt ', ' R '). ReadLines ()] #按行读取文件内容, and go to the space.
for I in userpasslist:
Username = i.split (': ') [0]
Paasword = I.split (': ') [1]
If user = = Username and passwd = = Paasword:
flag = 1
Break
If Flag = = 1:
Break
Else:
Count + = 1
If flag = = 1:
Print ("Login Successful")
Else:
Print ("Login failed")
Else:
Print ("Input error, SX")

1.python Language Implementation user logon 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.