Update pickle_idea.py
在生词簿每个单词后面,加上两个按钮,熟悉与不熟悉。如果点熟悉,就将生词簿中该单词后面记录的添加次数减一,直至减为0,就将该单词从生词簿中移除;如果点不熟悉,就将生词簿中该单词后面记录的添加次数加一。pull/1/head
parent
9b7b5279db
commit
643e0c4eee
|
@ -7,6 +7,7 @@
|
||||||
# Task: incorporate the functions into wordfreqCMD.py such that it will also show cumulative frequency.
|
# Task: incorporate the functions into wordfreqCMD.py such that it will also show cumulative frequency.
|
||||||
|
|
||||||
import pickle
|
import pickle
|
||||||
|
from datetime import datetime
|
||||||
|
|
||||||
|
|
||||||
def lst2dict(lst, d):
|
def lst2dict(lst, d):
|
||||||
|
@ -53,7 +54,22 @@ def save_frequency_to_pickle(d, pickle_fname):
|
||||||
pickle.dump(d2, f)
|
pickle.dump(d2, f)
|
||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
|
def unfamiliar(path,word):
|
||||||
|
f = open(path,"rb")
|
||||||
|
dic = pickle.load(f)
|
||||||
|
dic[word] += [datetime.now().strftime('%Y%m%d%H%M')]
|
||||||
|
fp = open(path,"wb")
|
||||||
|
pickle.dump(dic,fp)
|
||||||
|
|
||||||
|
def familiar(path,word):
|
||||||
|
f = open(path,"rb")
|
||||||
|
dic = pickle.load(f)
|
||||||
|
if len(dic[word])>1:
|
||||||
|
del dic[word][0]
|
||||||
|
else:
|
||||||
|
dic.pop(word)
|
||||||
|
fp = open(path,"wb")
|
||||||
|
pickle.dump(dic,fp)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue