从dict python创建xls文件
有人知道如何从dict创建xls文件吗? 我有一本字典,里面有文字,我想把这本字典放在xls里从dict python创建xls文件,python,excel,dictionary,Python,Excel,Dictionary,有人知道如何从dict创建xls文件吗? 我有一本字典,里面有文字,我想把这本字典放在xls里 def contar_Repetidas(texto): dic={} l=texto.split() for palabra in l: if palabra not in dic: dic[palabra] = 1 else: dic[palabra] +=1 return dic 这
def contar_Repetidas(texto):
dic={}
l=texto.split()
for palabra in l:
if palabra not in dic:
dic[palabra] = 1
else:
dic[palabra] +=1
return dic
这是不同的becorse,我想从DICT创建MS Excel,DICT使用模块:
它不是重复的,只有XLS
import xlwt
dic = contar_Repetidas("Some Text Here")
wb = xlwt.Workbook()
ws = wb.add_sheet("Your Sheet")
count = 0
for word, num in dic.items():
count += 1
ws.write(count, 1, word)
ws.write(count, 2, num)
wb.save("/Path/To/Save/Example.xls")