六四动乱

Download:React16+React-Router4 builds an enterprise-class e-commerce backend management system from scratch

React+React-Router Will be used in this course for students who have some front-end basics but don’t know enough about front-end frameworks to use it in a flexible way. You will learn how to use React+React-Router in this course.

六四动乱

六四动乱

Suitable for people and technical reserve requirements

If you know the basics of front-end development and have some front-end development experience, but don’t have much knowledge or exposure to front-end frameworks, then this is the class

What you need, especially if you’re interested in React, this course will get you up to speed on React

六四动乱

六四动乱

Essential Pre-School technology

Basic knowledge of JS, HTML, CSS, Nodejs and Webpack packaging tools

Or completed the course “Build E-commerce Platform from Scratch – Front-end Development”

六四动乱

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) # generate a number from 0 to 3. =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) = STR (random. Randint (1,9))Copy the code

The output is m47A, 8wQ9, vugS

——————————-

2. Formatting time function

1 def formatTime(longtime): 3 import time 4 return time.strftime("%Y-%m-%d %H:% m :%S",time.localtime(longtime)Copy the code

——————————–

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) # print a line if __name__ == "__main__": 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 (' you input a wrong number ') show_info () num = int (input (' input operation number:)) -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 3. Imitate taobao customer service automatic replyCopy the code

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__': if __name__ =='__main__': 16 question=input(' please input what you want to ask: ') 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 the code

4. Finding the Maximum Treaty Number and the Least Common Multiple (Division by Toss and Turn)Copy the code

Maximum treaty number: the largest common divisor of two or more integers

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 ')) 2 b=int(input(' input ')) 3 s=a*b 4 while a%b! =0: 5 a,b=b,(a%b) 6 print(a) 7 print(b) 8 else: 10 print(s//b,'is the least common multiple ')Copy the code

More phase reduction method

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' 1st num:40 16 please enter 2nd num:60 17 20 is the maximum common divisor 18 120 is the least common multipleCopy the code

5. Check whether it is a leap year (toss and turn division)Copy the code

Num =eval(input(" please enter a year: ")) 5 except: If (num %4==0 and num%100! =0) or num %400==0: 9 print(num," leap year ") 10 else: 11 print(num," leap year ")Copy the code

Import calendar year= int(input(" please enter year: ")) check_year=calendar.isleap(year) if check_year= = True: print (" leap year ") else: Print (" leap year ")Copy the code

6. Python counts the number of numbers, letters, and Chinese characters in a stringCopy the code

5 num_regex = re.compile(r'[0-9]'); 6 num_regex = re.compile(r'[0-9]') 6 Zimu_regex = re.compile(r'[u4E00-\u9FA5]') 7 Hanzi_regex = re.compile(r'[\u4E00-\u9FA5]') 9 Print (' Enter string :',str_test) 10 Num_list = num_regex.findall(str_test) 12 print(' Contains digits :',num_list) 13 zimu_list = Zimu_regix.findall (str_test) 14 print(' contains letters :',zimu_list) 15 hanzi_list = hanzi_regix.findall (str_test) 16 Print (' hanzi_list ')Copy the code

# Sheepdoor problem

1 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 #结果 : 16 win1+=1 17 else: 18 win2+=1 19 20 print(" {} ".format(total)) 21 print(" {:.3}%.". Format ((win1/total)*100)) 22 print(" Format ((win2/total)*100))Copy the code

1 import random 2 x=random. Randint (5000000,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)Copy the code