码迷,mamicode.com
首页 > 编程语言 > 详细

python的第一个脚本

时间:2014-05-21 01:19:11      阅读:391      评论:0      收藏:0      [点我收藏+]

标签:python      

第一个简单的python脚本

#!/usr/bin/python
#
import os
file_1=‘user.txt‘
file_2=‘lock.txt‘
#put an account_list
f=file(file_1)
accout_list=f.readlines()
f.close()
#put a list of the lock user
f = file(file_2)
lock_list= []
for i in f.readlines():
line = i.strip(‘\n‘)
lock_list.append(line)
f.close()
#main
Name=raw_input("input the user name:").strip()
Password=raw_input("input the user‘s password:").strip()
while True:
if len(Name) == 0:
print "you user name is blank,do it again"
Name=raw_input("input the user name:").strip()
continue
elif len(Password) == 0:
Password=raw_input("input the user‘s password:").strip()
print "your password is blank,do it again"
continue
else:
break
while True:
# insert a label to jungle the loginchange
loginchange = False
if Name in lock_list:
print "the user is lock in !"
exit()
for line in accout_list:
line = line.split()
# insert a correct username
if Name == line[0]:
loginchange = True
for i in range(3):
if Password == line[1]:
break
else:
print "the password is not correct,insert again!"
Password=raw_input("input the user‘s password:").strip()
if i == 2:
print "the user is lock in !"
# insert the wrong user into the lock_file
f = file(file_2,‘a‘)
f.write(‘%s\n‘ %Name)
f.close()
exit()
#
continue
break
else:
continue
if loginchange is True:
break
else:
print "the user is not exist"
answer=raw_input("do you want to insert again?(y/n)")
if answer == "y" :
Name=raw_input("input the user name:").strip()
Password=raw_input("input the user‘s password:").strip()
continue
else:
exit()
print "welcome"

 

本文出自 “永无止境” 博客,请务必保留此出处http://joe51cto.blog.51cto.com/7680547/1413015

python的第一个脚本,布布扣,bubuko.com

python的第一个脚本

标签:python      

原文地址:http://joe51cto.blog.51cto.com/7680547/1413015

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!