from prettytable import PrettyTable
from xpinyin import Pinyin
p = Pinyin()
datas = "床前明月光\n疑似地上霜\n举头望明月\n低头思故乡"
def print_pinyin(data):
a = p.get_pinyin(data, "-", tone_marks='marks')
# 打印表格
tb = PrettyTable()
tb.header = False
tb.border = False
tb.add_row([i for i in a.split('-')])
tb.add_row([i for i in data])
print(tb)
for data in datas.split("\n"):
print_pinyin(data)
效果类似:
1684311051126.png
做个笔记,将汉字转拼音的时候可以用一下
网友评论