How to read the content of streamlit.delta_generator.DeltaGenerator object?

My code:

import streamlit as st
import streamlit.components.v1 as components

import json

danci = st.text_input("θ―·θΎ“ε…₯要ζŸ₯ζ‰Ύηš„ε•θ―")
fanhui = components.iframe("http://dict.iciba.com/dictionary/word/suggestion?word="+danci)

st.write(type(fanhui))

st.write(json.loads(fanhui))

I got feedback like this:

I want to get the key value and paraphrase value.
Is there a way can do this?
Thank you.

It’s already a JSON object so no need to convert. You should really be using requests.get() for this http request.

Thank you.
I figured it out, and I get the content that I want.

import streamlit as st
import requests
import json

danci = st.text_input("θ―·θΎ“ε…₯要ζŸ₯ζ‰Ύηš„ε•θ―")
fanhui = requests.get("http://dict.iciba.com/dictionary/word/suggestion?word="+danci)
data1 = fanhui.text
data2 = json.loads(data1)
for i in range(len(data2["message"])):
	st.write(data2["message"][i]["key"],data2["message"][i]["paraphrase"])

2 Likes

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.