Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/apache-spark/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何在Streamlight中使用multiselect执行特定任务?_Python_Machine Learning_Streamlit - Fatal编程技术网

Python 如何在Streamlight中使用multiselect执行特定任务?

Python 如何在Streamlight中使用multiselect执行特定任务?,python,machine-learning,streamlit,Python,Machine Learning,Streamlit,我想根据streamlight multiselect选项(特定任务)执行一个或两个操作,但我看不出我做错了什么。拜托,你知道怎么解决吗 我的代码: 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(

我想根据streamlight multiselect选项(特定任务)执行一个或两个操作,但我看不出我做错了什么。拜托,你知道怎么解决吗

我的代码:

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)

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)


非常感谢乔纳森·R。!