1

我想根据 STREAMLIT 多选选项(特定任务)执行一项或两项操作,但我看不出我做错了什么。请,关于如何解决它的任何想法?

我的代码:

import streamlit as st

calculation = st.multiselect("Select one or both operations:", ('SUM','DIV'))

if calculation =='SUM':st.write(2+2)

elif calculation =='DIV':st.write(10/2)
4

1 回答 1

3

st.multiselect返回一个包含所选选项的数组

import streamlit as st

calculation = st.multiselect("Select one or both operations:", ('SUM','DIV'))

if 'SUM' in calculation:
    st.write(2+2)

if 'DIV' in calculation:
    st.write(10/2)

于 2020-02-19T00:04:48.873 回答