download:Python Flask Quick start and advanced

Those of you who have mastered the basic syntax of Python know that the next step is to learn the Python framework, but what framework to choose and how to get through the “lag” period quickly are always difficult problems. We suggest that Flask can be used for transition and initiation. The “light” characteristic of Flask itself makes your learning less “heavy”. After mastering the core knowledge, you will be able to develop and gain a sense of achievement, which will make learning more motivated. FLask’s ability to “quickly” develop various types of applications is very well accepted in the Python Web space

Suitable for people who know the basic syntax of Python but don’t know what to do next students who are new to Python Web development

Basic knowledge of Python syntax and MySQL (basic knowledge of adding, deleting, modifying and checking)

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) : “) ‘)