Download:MySQL Enhancement course provides a comprehensive overview of MySQL architecture design

How to get optimal MySQL performance? How to set up a MySQL high availability cluster? How to build a stable and efficient MySQL environment

Suits the crowd

Suitable for students with self-learning ability, master the basic knowledge of Linux system and MySQL database 1. Four digit alphanumeric textual code generation example

1 import random 2 if name ==”main”: 1 import random 2 if name ==”main”: 1 import random 2 if name ==”main”: 5 index=random. Randrange (0,4) =i and index +1 ! = I: 7 checkCode += CHR (random.randint(97,122)) # generate a lowercase letter in a z 8 elif index +1== I: 9 checkcode += CHR (random.randint(65,90)) # generate A capital letter in A~Z 10 else: 11 print(checkCode) (m47A, 8wQ9, vugS

2. Formatting time function

3 import time4 return time.strftime(“%Y-%m-%d “) 3 def formatTime(longtime): longtime 3 import time4 return time.strftime(“%Y-%m-%d %H:%M:%S”,time.localtime(longtime))

3. Record the display log instance

Import time def show_info(): print(” “) def write_loginfo(username): print(” “) def write_loginfo(username): Param username: username “”” with open(‘log.txt’,’a’) as f: String = “User name: {} Login time: {}\n”.format(username ,time.strftime(‘%Y-%m-%d %H:%M:%S’,time.localtime(time.time()))) f.write(string) def Read_loginfo (): “”” “”” “”” with open(‘log.txt’,’r’) as f: while True: line = f.readline() if line == “: Print (line) # if name == “main”:

Enter a user name

While len(username) < 2: Print (' username = 1 ') print(' username = 1 ') print(' username = 1 ') print(' username = 1 ') print(' username = 1 ') print(' username = 2 ') Print (' Password should be at least 6 characters long ') password = input(' Please enter password: Num = int(input(' ') print(' ') print(' ') write_loginfo(username) If num == 0: print(' num ') break elif num == 1: Print (' print ') read_loginfo() show_info() num = int(input(' print ') else: Print (' print ') show_info() num = int(input(' print ')Copy the code

3. 3 def find_answer(question): 4 with open(‘reply.txt’,’r’) as f: 5 while True: 6 line=f.readline() 7 if not line: # can also for the if the line = = 9 ‘8 break keyword = line. The split (‘ |’) [0] 10. Reply = line split (‘ | ‘) [1] 11 if keyword in question: 15 if name ==’main’: 16 question=input(‘ please input what you want to ask: ‘) 17 while True: 18 if question==’bye’: 19 break 20 reply=find_answer(question) 21 if not reply: 22 question=input(” I don’t know what you are talking about, you can ask something about order, account and payment (to exit please enter bye) : “) 24 print(reply) 25 question=input(” You can ask something about order, account and payment (please enter bye to exit) : “) ‘) 27 Copy code Copy code 4. Find the maximum number of treaties and least common multiple (division by toss and turn) Maximum number of treaties: refers to two or more integers common divisors of the largest

Least common multiple: The common multiple of two or more integers is called their common multiple, where the least common multiple other than 0 is called the least common multiple of the integers

Relation: Product of two numbers = least common multiple * maximum treaty number

1 a=int(input(‘ input 1:’)) 2 b=int(input(‘ input 2:’)) 3 s=a*b 4 while a%b! =0: 5 a,b=b,(a%b) 6 print(a) 7 print(b) 8 else: Print (s//b,’is the least common multiple ‘

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

Import random as r 2 3 # 4 total=1000000 #1000,1W,10W,100W 5 # win1=0 7 win2=0 8 9 range(total): 11 man= r.rint (1,3) 12 car= r.rint (1,3) 13 #结果 : Print ({:.3}%.”) print({:.3}%.”) print({:.3}%.”) print({:.3}%.”)

100)) 22 print({:.3}%.”. Format ((win2/total)

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: Format (nochange/x) print(nochange/x) print(nochange/x) print(nochange/x)