您的位置:首页 > 其它

review what i studied `date` - 2017-4-17

2017-04-18 01:11 260 查看
老男孩day1作业:login
[root@xuhui-1 day1]# cat day1homework.py
#!/bin/env python
import sys
#加载sys模块 使用退出命令
file = 'user.lock'
#黑名单文件
f = open(file,'a')
#以附加模式打开文件,没有则创建
f.close()
#关闭一次下次在用其他模式调用
f = open(file,'r')
#读取模式打开
login = "0"
for fail in range(0,3):
username = ""
password = ""
while username == '' and login == "0":
#判断两个条件当没有登录和用户名为空时循环
username = raw_input('Pls input your username:').strip()
if username == "":
print "username can't be empty "
continue
elif username in f.read():
print "user is locked"
sys.exit()
#检测到用户名存在于黑名单中,退出
while password == '' and login == "0":
password = raw_input('Pls input you password:').strip()
if password == "":
print "password can't be empty "
continue
if username == 'xuhui' and  password == '123456':
f.close()
print 'login successful'
login = '1'
#设置login位 为1不会再去开启两个while循环
break
else:
print 'username or password incorrect'
else:
if fail == 2 and login == "0":
#当输入了三次还没有登录则加入黑名单
f.close()
print 'login lock'
f = open(file,'a')
f.write(username)
f.close()


数据库如何存放图片
1、将图片转换成二进制流存入数据库
2、在数据库中存放图片的url
http://soft.chinabyte.com/database/91/12333591.shtml php+mysql存入图片
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  2017