download:Play N kinds of enterprise-level solutions, laugh proud distributed development
Distributed: programmer eternal proposition. Brother Liao has launched a rare Java distributed course on the whole network to teach you the secrets of distributed training, help you build a perfect distributed knowledge system, and help you “hard skills + soft power” to the next level. The course includes distributed ID, distributed Session, distributed task scheduling, distributed flow limiting, sub-database sub-table, distributed transaction six topics, cases cover users, reports, seconds kill, orders and other classic scenarios, enterprises commonly used distributed actual combat cases & solutions, complete package for you!
Redis 1 import random 2 if name ==”main”: 4 for I in range(4): 5 index=random. Randrange (0,4) # generate a 0 3 number 6 if index! =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)