Spaces:
Running
Running
| import gradio as gr | |
| def analyze_text(text): | |
| return { | |
| "字符数": len(text), | |
| "单词数 (空格分隔)": len(text.split()), | |
| "行数": len(text.splitlines()) | |
| } | |
| def create_ui(): | |
| with gr.Row(): | |
| inp = gr.Textbox(lines=5, label="输入文本") | |
| out = gr.JSON(label="统计结果") | |
| btn = gr.Button("分析") | |
| btn.click(analyze_text, inp, out) | |