from openpyxl import load_workbook
from xpinyin import Pinyin
# 默认可读写,若有需要可以指定write_only和read_only为True
wb = load_workbook('1.xlsx')
# a_sheet = wb.get_sheet_by_name('Sheet1')
sheet = wb.active
a=""
for row in sheet.rows:
for cell in row:
if cell.value is None:
p = Pinyin()
d=p.get_pinyin(cell.value, '')#全拼
else:
p = Pinyin()
d=p.get_pinyin(cell.value, '')#全拼
a+=cell.value+","+str(d)+"\n"
print(a)