# -*- coding: utf-8 -*-
import xlrd
import json
#python3 第一列 英文, 中文,wordfrom
wb = xlrd.open_workbook(filename="words.xlsx") # 打开文件
cjSheet = wb.sheet_by_name("Sheet1") # 通过名字获
xx =1
wordsjson =[]
for row in range(cjSheet.nrows):
# for col in range(cjSheet.ncols):
cellValue = cjSheet.cell_value(row, 0)
item ={"english": cjSheet.cell_value(row, 0),"chinese": cjSheet.cell_value(row, 1),"wordfrom": cjSheet.cell_value(row, 2), }
print ("cell : " + cellValue)
wordsjson.append(item)
# cjSheet.cel
xx =1
filename='names.json'
with open(filename,'w',encoding='utf-8') as file_obj:
json.dump(wordsjson,file_obj,ensure_ascii=False)