Jun-04-2017, 11:45 AM
Hi guys
I am currently trying to get my python program to save and load from one text file
Basically i am creating a student record program which writes and loads within the programme, I am using pickle at the moment. I have successfully got each record to save in a individual text file.
However I am unsure of number 6,
Could anyone direct me to an example I can see for question 5 and 6 please,
5. retrieve and display the details of any student when Mr Lee enters the student’s unique ID
number.*
6 create at least three different reports that Mr Lee might need
I am currently trying to get my python program to save and load from one text file
Basically i am creating a student record program which writes and loads within the programme, I am using pickle at the moment. I have successfully got each record to save in a individual text file.
However I am unsure of number 6,
Could anyone direct me to an example I can see for question 5 and 6 please,
5. retrieve and display the details of any student when Mr Lee enters the student’s unique ID
number.*
6 create at least three different reports that Mr Lee might need
import pickle import os.path def savedata(): """ This method add new entry. @take input as a name from console. @take input as a phone from console.. @ save name and phone in file """ studentld = input("Please enter your name: ") firstname = input("Enter your Mobile number : ") lastname = input("Enter your Mobile Network : ") outFile = open(studentld + '.txt', 'wb') pickle.dump({ "studentld": studentld, "firstname": firstname, "network": lastname}, outFile) outFile.close() print("Successfully added a new name and number & network for:"+ studentld+ "\n") def get_entry(): """ This method print number already added. @take input as a name from console. @find antry of input name and print mobile number """ saveln = input("Please enter your name:") try: open_file = open(saveln + '.txt', 'rb') load_file = pickle.load(open_file) print("Your name is: "+load_file['studentld']+"\n") print("Your telephone number: "+load_file['firstname']+"\n") print("Your telephone network: "+load_file['lastname']+"\n") open_file.close() except: print("\n File does not exist!!")