函數簽名
st.text_input(label, value="", max_chars=None, key=None, type="default", help=None, autocomplete=None, on_change=None, args=None, kwargs=None, *, placeholder=None, disabled=False)
參數 | 說明 |
---|---|
label (str) | 一個簡短的標簽,向用戶解釋此輸入的用途。 |
value (any) | 此小部件首次呈現時的文本值。這將在內部強製轉換為 str 。 |
max_chars (int or None) | 文本輸入中允許的最大字符數。 |
key (str or int) | 一個可選的字符串或整數,用作小部件的唯一鍵。如果省略,將根據其內容為小部件生成一個 key 。相同類型的多個小部件可能不共享相同的鍵。 |
type (str) | 文本輸入的類型。這可以是"default"(用於常規文本輸入)或"password"(用於屏蔽用戶鍵入值的文本輸入)。默認為"default"。 |
help (str) | 顯示在輸入旁邊的可選工具提示。 |
autocomplete (str) | 將傳遞給 <input> 元素的 autocomplete 屬性的可選值。如果未指定,則此值將設置為 "new-password" 用於 "password" 輸入,並將空字符串設置為 "default" 輸入。有關更多詳細信息,請參閱https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/autocomplete |
on_change (callable) | 當此 text_input 的值更改時調用的可選回調。 |
args (tuple) | 傳遞給回調的可選參數元組。 |
kwargs (dict) | 一個可選的 kwargs 字典傳遞給回調。 |
placeholder (str or None) | 當文本輸入為空時顯示的可選字符串。如果為 None,則不顯示任何文本。此參數隻能由關鍵字提供。 |
disabled (bool) | 一個可選的布爾值,如果設置為 True,則禁用文本輸入。默認值為假。此參數隻能由關鍵字提供。 |
返回 | 說明 |
(str) | 文本輸入小部件的當前值。 |
示例
title = st.text_input('Movie title', 'Life of Brian')
st.write('The current movie title is', title)
相關用法
- Python Streamlit st.text_area用法及代碼示例
- Python Streamlit st.text用法及代碼示例
- Python Streamlit st.title用法及代碼示例
- Python Streamlit st.time_input用法及代碼示例
- Python Streamlit st.table用法及代碼示例
- Python Streamlit st.experimental_singleton.clear用法及代碼示例
- Python Streamlit st.bokeh_chart用法及代碼示例
- Python Streamlit st.caption用法及代碼示例
- Python Streamlit st.area_chart用法及代碼示例
- Python Streamlit st.cache用法及代碼示例
- Python Streamlit st.experimental_singleton用法及代碼示例
- Python Streamlit st.empty用法及代碼示例
- Python Streamlit st.error用法及代碼示例
- Python Streamlit st.video用法及代碼示例
- Python Streamlit st.vega_lite_chart用法及代碼示例
- Python Streamlit st.slider用法及代碼示例
- Python Streamlit st.header用法及代碼示例
- Python Streamlit st.container用法及代碼示例
- Python Streamlit st.form_submit_button用法及代碼示例
- Python Streamlit st.form用法及代碼示例
- Python Streamlit st.plotly_chart用法及代碼示例
- Python Streamlit st.bar_chart用法及代碼示例
- Python Streamlit st.code用法及代碼示例
- Python Streamlit st.experimental_memo.clear用法及代碼示例
- Python Streamlit st.warning用法及代碼示例
注:本文由純淨天空篩選整理自streamlit.io大神的英文原創作品 st.text_input。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。