1, can be in command line, enter the word or phrase
2, stored in a file and the date of the record to add
3, save that success or word is
4, prompt the existing total words
5, the program can be run repeatedly (normal function of guarantee, speaking, reading and writing)
Programming the basic train of thought is as follows:
1, use a dictionary to store the word and the corresponding date (because it is the first time, therefore the word definition not included) as key words, a value that contains definitions (next add) and record the date on the tuple,
2, the pickle module is used to keep the dictionary, the corresponding requirements in the 5 points, can deposit can be read,
3, in circulation ways for words and record for many times, the enter key to exit the loop
A: 4, branch, loop join words recorded, only print recorded tip; Situation 2: word did not record, record the words; Case 3: enter the empty string, break
5, we need to import time module
I can start code code after a train of thought, the most began to write a small program initialization of my words, the program written into the first a memorable words: hello, and then create the PKL file, give priority to program to lay good road, later can also take this small program to a key to empty, attach a small program I wrote the first paragraph is initialized, and then attach the first time I write the main program code, as well as the operation result,
As shown, there is the bug: (attached above, ooo I write a word )
Behind the words from two won't increase, and the input words will cover the second word, also will only appear once again open applications a word: hello,
It makes me very confused, so I have modified the cycle structure, modify the key way to add the dictionary... Not all,
So the next day I go to ask one of our professional teacher (is he always want us to self-study python, python of all kinds of good every day, of course I also learn a guider of python), he will help me to see at noon, and then help me changed the location of the file, then the code works,
Words can be increased, not stack, (attached code and operation result)
(thank you very much my teacher )
But I still don't know I what is the cause of the error, also saw the please bosses can help an thank you very much!
I also learn python, more than 10 days is a prospective of new, also learned a little bit before high school, basic (compulsory learning) in the freshman year, learn some of the C language (stroke all the way ha ha ha ha ha ha), python feels good, every day to write code is good also ha ha ha ha ha ha,
Thank you can see my post, thank you very much! And I do hope of new can also come on! Try hard! 希望大佬多财多金多发
CodePudding user response:
Behind the second phase will continue to write, will join the translation of the interface, and then import the GUI interface forms should be more comfortable