How to select single or multiple rows in st.dataframe and return the selected data?

Thank you very much. Your idea is very clever! However, it may be a bit cumbersome to operate if there are a lot of rows in st.dataframe. I hope to be able to achieve single or multiple selection by clicking on the rows in st.dataframe, with the selected rows changing color to indicate that they have been selected, and to save and retrieve the selected row data through st.session_state.