添加一个web API,以json格式显示当前用户的所有生词,以及添加某生词的总次数
parent
868fed795d
commit
1e846e5960
|
@ -29,16 +29,12 @@ def api_bp(username):
|
|||
result = []
|
||||
user_freq_record = path_prefix + 'static/frequency/' + 'frequency_%s.pickle' % (username)
|
||||
s = pickle_idea2.load_record(user_freq_record)
|
||||
print(json.dumps(s))
|
||||
wordlist = helper(s,result)
|
||||
results = "{"
|
||||
i=0
|
||||
results = {}
|
||||
|
||||
for word in wordlist:
|
||||
if i!=len(wordlist)-1:
|
||||
results +='"' + word +'":' + str(len(s[word])) +","
|
||||
i=i+1
|
||||
else:
|
||||
results += '"' + word + '":' + str(len(s[word]))
|
||||
results+="}"
|
||||
|
||||
|
||||
results[word]=len(s[word])
|
||||
return results
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue