import gradio as gr import docx import pandas as pd from docx import Document def wd(x): doc=Document(x) all_paragraphs = document.paragraphs t=all_paragraphs[0].text return t demo=gr.Blocks(css="#jsc:hover{background-color: red;}") with demo: with gr.Tabs(): with gr.TabItem("读取word"): file_input = gr.File(file_count="single",label="请选择需要读取的word文件",show_label=True) text_output = gr.Textbox(label="输出读取文本",show_label=True) dq_button = gr.Button("开始读取>>") dq_button.click(wd, inputs=file_input, outputs=text_output,api_name="word-text") demo.launch()