In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces how to achieve Python student management system and generate exe executable files, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let Xiaobian with you to understand.
I. preparatory work
Prepare the software used.
Python 3.8
Pycharm 2021.2
Knowledge point
Basic syntax of Python
Basic data types and structures
Basic logic control statement
Actual combat small projects
II. Code flow
= assignment is to receive the content to the left of the equal sign with the name of the variable to the right of the equal sign
Msg = "" * * Welcome to [Student Information Management system] v1.0 Please select the operation you want to do. New student information 2. Display all information 3. Inquire about student information 4. Delete student information 5. Modify student information 0. Exit the system * * "
Student information is saved in a list, and the dictionary data type is in it.
Student_info = [{'name': 'Muzi', 'Chinese': 60, 'Mathematics': 60, 'English': 60, 'Total score': 180}, {'name': 'Siyue', 'Chinese': 60, 'Mathematics': 60, 'English': 60, 'Total score': 180}, {'name': 'Luoqi', 'Chinese': 60, 'Mathematics': 60 'English': 60, 'Total score': 180},]
The whole endless cycle.
While True: print (msg) # output function print # = all custom variables on the left cannot start with a number. It is not recommended to use keywords as variable names. It is recommended that variables be named. The input content data type is string data type input_world = input ('Please enter what you want to do:') # print ('the action you choose is:' Input_world) # statement for multi-conditional judgment one = assigns two = compares whether they are equal # comment if input_world = = '1comment: # determine whether input_world (input) is equal to 1 print (' new student information') name = input ('please enter the student's name:) chinese = input (' please enter Students' Chinese scores:') math = input ('Please enter students' math scores:') English = input ('Please enter students' English scores:') # len () = 10 Statistical elements if more or less to judge total = int (chinese) + int (math) + int (English) # the total score is transformed into integer dit = {'name': name 'Chinese': chinese, 'Mathematics': math, 'English': English, 'Total score': total,} student_info.append (dit) elif input_world = = '2statistics: print (' Show all information') print ('name\ t Chinese\ t Mathematics\ t English\ t Total score')
For ergodic loop
For student in student_info: # spaced tab key four spaces\ nWrap # {} Dictionary data types extract content according to key value pair (extract content to the right of colon according to the content to the left of colon) # method of dictionary value student ['Chinese'] print (student ['name'] +'\ t' + str (student ['Chinese) ']) +'\ t\ t' + str (student ['Mathematics']) +'\ t\ t' + str (student ['English']) +'\ t\ t' + str (student ['Total']))
Query information
Elif input_world = '3students: print (' query student information') input_name = input ('Please enter the name of the student you want to query:') for student in student_info: if student ['name'] = = input_name: print ('name\ t Chinese\ t math\ t English\ t total score') # neat format Print (student ['name'] +'\ t' + str (student ['Chinese']) +'\ t\ t' + str (student ['Mathematics']) +'\ t\ t' + str (student ['English']) +'\ t\ t' + str (student ['Total score']) ) break # jump out of the loop else: print ('incorrect student information Failed to query information')
Delete information
Elif input_world = '4students: print (' delete student information') input_name = input ('Please enter the name of the student you want to delete:') for student in student_info: if student ['name'] = = input_name: # list how to delete element # pop pop-up list element and delete student_info.remove ( Student) print (student ['name'] 'message deleted successfully') break else: print ('incorrect student information, failed to delete information')
Modify information
Elif input_world = '5students: print (' modify student information') input_name = input ('Please enter the name of the student you want to modify:') for student in student_info: if student ['name'] = input_name: chinese = input ('please re-enter Chinese scores:') math = input ('please re-enter math scores:' ) english = input ('Please re-enter English scores:') total = int (chinese) + int (math) + int (english) student ['Chinese'] = chinese student ['Mathematics'] = math student ['English'] = english student ['Total score'] = total break else: print ('incorrect student information Failed to modify information')
Quit
Elif input_world = '0percent: print (' exit the system') break
Complete code
Msg = "" * * Welcome to [Student Information Management system] v1.0 Please select the operation you want to do. New student information 2. Display all information 3. Inquire about student information 4. Delete student information 5. Modify student information 0. Student_info = [{'name': 'Muzi', 'language': 60, 'Mathematics': 60, 'English': 60, 'Total score': 180}, {'name': 'month', 'language': 60 'Math': 60, 'English': 60, 'Total score': 180}, {'name': 'Luoqi', 'Chinese': 60, 'Mathematics': 60, 'English': 60, 'Total score': 180} ] # endless loop while True: print (msg) # output function print input_world = input ('Please enter what you want to do:') if input_world = '1input: # determine whether input_world (input) is equal to 1 print (' new student information') name = input ('please enter the student's name:') chinese = Input ('Please enter students' Chinese scores:') math = input ('Please enter students' math scores:') English = input ('Please enter students' English scores:') total = int (chinese) + int (math) + int (English) # Total score conversion dit = {'name': name 'Chinese': chinese, 'Mathematics': math, 'English': English, 'Total score': total } student_info.append (dit) elif input_world = = '2messages: print (' display all information') print ('name\ t Chinese\ t math\ t English\ t total score') for student in student_info: print (student ['name'] +'\ t' + str (student ['language']) +'\ t\ t' + str (student ['Mathematics']) +'\ t\ t' + str (student ['English']) +'\ t\ t' + str (student ['Total']) elif input_world = ='3': print ('query student information') input_ Name = input ('Please enter the name of the student you want to query:') for student in student_info: if student ['name'] = = input_name: print ('name\ t Chinese\ t math\ t English\ t total score') # neat format print (student ['name'] +'\ t'+ Str (student ['Chinese']) +'\ t\ t' + str (student ['Mathematics']) +'\ t\ t' + str (student ['English']) +'\ t\ t' + str (student ['Total score'])) Break # jumps out of the cycle else: print ('student information is incorrect Failed to query information') elif input_world = = '4students: print (' delete student information') input_name = input ('Please enter the name of the student you want to delete:') for student in student_info: if student ['name'] = = input_name: # list how to delete the element # pop Pop up the list element and delete student_info.remove (student) print (student ['name'] 'message deleted successfully') break else: print ('incorrect student information Failed to delete information') elif input_world = '5permission: print (' modify student information') input_name = input ('Please enter the name of the student you want to modify:') for student in student_info: if student ['name'] = = input_name: chinese = input ('Please re-enter the language score:') Math = input ('Please re-enter math scores:') english = input ('Please re-enter English grades:') total = int (chinese) + int (math) + int (english) student ['Chinese'] = chinese student ['Mathematics'] = math student ['English' ] = english student ['Total score'] = total break else: print ('incorrect student information Failed to modify the information') elif input_world = '0quit: print (' exit the system') break else: print ('Please enter the correct action') 3. Package the exe executable
First install the module Pyinstaller, win+r to open the search box, enter cmd enter to open the command prompt window.
Enter pip install Pyinstaller to install successfully.
Your code save path should be changed to English as much as possible so as not to make a mistake.
For example, if your code is on disk D, you can change the directory to disk D at the command prompt.
Then enter CD + space + your file address, for example, I put it in folder 666 on disk D.
Start packing at this time, type pyinstaller-F-w in the command prompt window plus your code file name, and be sure to put the suffix. py
Explain here,-F is to generate exe files, be sure to use uppercase, or it will fail;-w can be uppercase and lowercase, it is to solve the problem of flash black box when running exe files after successful packaging, try to add, you do not want to send it to others when pretending to be forced.
Then enter the car and start packing.
Open the dist folder and put your packaged files right here.
Run it and have a look
New information
Query information
Thank you for reading this article carefully. I hope the article "how to implement Python student management system and generate exe executable files" shared by the editor will be helpful to everyone. At the same time, I also hope that you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.