高級Redis應用進階課 一站式Redis解決方案

download: 高級Redis應用進階課 一站式Redis解決方案 【完結】

本課程以一個實戰項目爲主線,整合Redis各類問題場景,不斷改造項目,以問帶學。學完本課後,面對Redis相關問題,你將可以快速進行排查與修復,不管實際工做仍是跳槽面試你都將遊刃有餘。web

適合人羣
對Redis有興趣,但不懂如何和項目深度結合的後端工程師
瞭解Redis平常操做,但不懂得Redis底層原理的後端工程師
遇到Redis故障徹底沒有思路,不知如何解決的後端工程師
技術儲備要求
後端web開發基礎面試

1 a=int(input('please enter 1st num:'))
2 b=int(input('please enter 2nd num:'))
3 s=a*b
4
5 while a!=b:
6 if a>b:
7 a-=b
8 elif a<b:
9 b-=a
10 else:
11 print(a,'is the maximum common divisor')
12 print(s//a,'is the least common multiple')
13
14 #運行結果
15 please enter 1st num:40
16 please enter 2nd num:60
17 20 is the maximum common divisor
18 120 is the least common multiple
複製代碼
5。判斷是否爲閏年 (展轉相除法)
複製代碼
1 # 判斷是否爲閏年
2 while True:
3 try:
4 num=eval(input("請輸入一個年份:"))
5 except:
6 print('輸入錯誤年份')
7 continue
8 if (num %4==0 and num%100 !=0) or num %400==0:
9 print(num,"是閏年")
10 else:
11 print(num,"不是閏年")
複製代碼正則表達式

複製代碼
import calendar後端

year = int(input("請輸入年份:"))
check_year=calendar.isleap(year)
if check_year == True:
print ("閏年")
else:
print ("平年")
複製代碼
6。Python統計字符串中數字,字母,漢字的個數
複製代碼
1 import re
2 str_test='abcdefgHABC123456中華民族'
3
4 #把正則表達式編譯成對象,若是常用該對象,此種方式可提升必定效率
5 num_regex = re.compile(r'[0-9]')
6 zimu_regex = re.compile(r'[a-zA-z]')
7 hanzi_regex = re.compile(r'[\u4E00-\u9FA5]')
8
9 print('輸入字符串:',str_test)
10 #findall獲取字符串中全部匹配的字符
11 num_list = num_regex.findall(str_test)
12 print('包含的數字:',num_list)
13 zimu_list = zimu_regex.findall(str_test)
14 print('包含的字母:',zimu_list)
15 hanzi_list = hanzi_regex.findall(str_test)
16 print('包含的漢字:',hanzi_list)
複製代碼
#羊車門問題dom

複製代碼
1 import random as r
2
3 #總次數
4 total=1000000 #1000,1W,10W,100W
5 #換與不換的獲勝次數
6 win1=0
7 win2=0
8
9 for i in range(total):
10 #模擬選擇過程
11 man=r.randint(1,3)
12 car=r.randint(1,3)
13 #結果:一開始爲車門,不換+1.
14 # 不然則一開始爲羊門,換+1.
15 if man==car:
16 win1+=1
17 else:
18 win2+=1
19
20 print("在{}次實驗中:".format(total))
21 print("若不更改門,獲勝機率爲{:.3}%.".format((win1/total)100))
22 print("若更改門,獲勝機率爲{:.3}%.".format((win2/total)
100))
複製代碼
複製代碼
1 import random
2 x=random.randint(5000,10000)
3 print(x)
4 change=0
5 nochange=0
6 for i in range(1,x+1):
7 a=random.randrange(1,4)
8 b=random.randrange(1,4)
9 if a==b:
10 nochange=nochange+1
11 else:
12 change=change+1
13 print("不更改選擇獲得汽車的機率爲{:.2f}".format(nochange/x))
14
15 print("更改選擇獲得汽車的機率爲{:.2f}".format(change/x))
複製代碼ide

相關文章
相關標籤/搜索