2017-04-20 23 views
0

我有一個在union_dicts字典的列表。爲了給你一個想法,它的結構如下從字典列表中製作幾個wordcloud

union_dicts = [{'bla' : 6, 'blub': 9}, {'lub': 20, 'pul':12}] 

(http://stardict.sourceforge.net/Dictionaries.php下載的實際名單是長許多倍,但是這是給的想法)

對於詞典的這個特殊的名單我想打一個wordcloud。這使得wordcloud功能如下(沒有錯一個):

​​

現在我已經寫了下面的代碼應該給每一個字典回到這一點。返回只給出了第一字典背在下面的下面的函數:

def bupol(): 
    for element in union_dicts: 
     return HTML(make_words(element)) 
bupol() 

我已經嘗試簡單地打印出來,但我只是得到'IPython的顯示對象',而不是實際的顯示。我確實希望顯示。產量也不起作用在這個功能和由於某種原因使用list = []以及list.apped()返回列表而不是以當前方式返回也不起作用。我很無能,因爲如何正確地迭代這個,所以我得到了union_dicts裏面的每個字典的顯示,這是一個字典列表。

回答

0

這樣的事情呢?

def bupol(): 
    result = [] 
    for element in union_dicts: 
     result.append(HTML(make_words(element))) 
    return result