2019_8_1python
生活随笔
收集整理的這篇文章主要介紹了
2019_8_1python
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
#函數 #函數是用來重復使用噠 #定義函數套路 ''' 1、首先要會寫出裸代碼,然后看看哪里是重復需要使用的 2、接下來將需要重復使用的代碼轉換成參數,帶入到函數中 函數格式 def funcName([param]): 執行體 [return] 函數調用 funcName() ''' 秒殺 def miaosha (user):if user == 'vip':print ('秒殺了')else:print ('沒有秒殺')
print('檢測是不是vip ')
miaosha('vip')
miaosha('bushivip') 商品有沒有貨 def shangpin(name):if name == '2':print('填寫信息')b = 0a = input('姓名')b = int(input('電話'))jiancha(a,b)else:print('沒貨哦,不賣給你')
def jiancha(a,b):if a != 'Joker' and b != 0:print('立馬出貨')else:print('不賣給你')
b = input('輸入要買啥 1、電腦 2、冰箱')
shangpin(b)
配送方位
def Check_Goods(g):G = ['汽車','火車','飛機']if g in G:Address()else:print('沒有這個貨')return Falsedef Check_Information(name,phone,Addr):is_OK = Trueif name == "" or name == " ":print('用戶名為空')is_OK = Falseif len(phone) != 11:print('電話不對勁啊')is_OK = Falseif Addr not in ['北京','山東']:print('不在配送范圍')is_OK = Falsereturn is_OK注冊界面
import time import random import numpy as np import stringdef Check_User(username,password):is_OK = TrueA = 'qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM'B = ',./;\'!@#$%^&*(_+|~'C = '1234567890'count1,count2,count3 = False,True,Falsefor i in username:if i in A:count1 = Trueif i in B:count2 = Falseif i in C:count3 = Trueprint(count1,count2,count3)if count1 and count2 and count3:print('OK')else:print('必須含有字母和數字,而且不能寫特殊字符熬')is_OK = Falseif len(password) < 6:print('必須6位以上')return is_OKdef Check_Phone(phone):is_OK = Trueif len(phone) != 11:print('電話不對勁啊')is_OK = Falsereturn is_OKdef Check_yzm():is_OK = Trues = string.ascii_lowercasestart_time = time.time()print('輸入驗證碼,快輸,10秒就過期了熬')str1 = ""for i in range(5):for i in range(0,4):a = random.choice(s)b = np.random.choice([1,2,3,4,5,6,7,8,9,0])c = random.choice([a,b])print(c,end="")str1 = str(str1)+str(c) print('')global_count += 1shuru = input('請輸入驗證碼,已經發了%d秒'%b)time.sleep(1)b += 1end_time = time.time()sub_time = end_time - start_timeif sub_time > 3:if global_count > 2:print('你是個機器人吧')exit()print('過期了熬,一會兒再給你一個熬')time.sleep(5)Check_yzm()else:if shuru == str1:print('輸對了')breakelse:is_OK = Falseprint('不對哦')return is_OKdef Login():global global_count = 0print('歡迎注冊')username = input('輸入用戶名')password = input('輸入密碼')res1 = Check_User(username,password)if res1:phone = input('輸入電話')res2 = Check_Phone(phone)if res2:res3 = Check_yzm()if res1 and res2 and res3: print('登陸成功') Login()
轉載于:https://www.cnblogs.com/Y139147/p/11284968.html
總結
以上是生活随笔為你收集整理的2019_8_1python的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 牛客假日团队赛6 D迷路的牛 (思维)
- 下一篇: dns轮训python