老男孩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存入圖片