在 st.write 的幫助下,我在 streamlit 中獲得了字典格式的輸出。如果我也使用 st.text,它會以相同的字典格式返回輸出。以下是我要起訴的輸出和代碼
with st.spinner("正在搜索相關信息.."):
如果按鈕:
結果=搜索(查詢,top_k=p,索引=索引,模型=模型)
結果的結果:
# st.write(str(result).replace('{', '').replace('}', '').replace('\'', '\"'))
st.text(結果)
我想要如下輸出
1. “PDF”:“2016 年 7 月 20 日.pdf”,“內容”:“1.總經理/副總經理,印度儲備銀行,發行','頁碼':'14' 2. 'Pdf': 'July 20, 2016.pdf', 'Content': 'reserve bank of India Department of Currency Management Master Notice – 2016-17', 'Page no': '3,3,3,3, 3' 3. 'Pdf': 'July 20, 2017.pdf', 'Content': '貨幣箱/後台密切監控假鈔的檢測並保持記錄。確保僅將經過適當分類和機器檢查的紙幣送入自動取款機/在櫃檯發行,並在紙幣處理和運輸過程中採取適當的保護措施,包括突擊檢查。', '頁碼': '5 ' 4.“pdf”:“2020年7月1日.pdf”,“內容”:“印度儲備銀行貨幣管理部”,“頁碼”:“2” 5. 'Pdf': 'April 1, 2021.pdf', 'Content': '(slbc), 貨幣管理常務委員會 (sccm), 國家級安全委員會 (slsc) 等', '頁碼': '3'
誰能幫我解決這個問題?
for i, result in enumerate(results):
st.write(str(i + 1) + '.' + str(result).replace('{', '').replace('}', '').replace('\'', '\" '))
輸出是:
1. “PDF”:“2016 年 7 月 20 日.pdf”,“內容”:“1.總經理/副總經理,印度儲備銀行,發行','頁碼':'14' 2. 'Pdf': 'July 20, 2016.pdf', 'Content': 'reserve bank of India Department of Currency Management Master Notice – 2016-17', 'Page no': '3,3,3,3, 3' 3. 'Pdf': 'July 20, 2017.pdf', 'Content': '貨幣箱/後台密切監控假鈔的檢測並保持記錄。確保僅將經過適當分類和機器檢查的紙幣送入自動取款機/在櫃檯發行,並在紙幣處理和運輸過程中採取適當的保護措施,包括突擊檢查。', '頁碼': '5 ' 4.“pdf”:“2020年7月1日.pdf”,“內容”:“印度儲備銀行貨幣管理部”,“頁碼”:“2” 5. 'Pdf': 'April 1, 2021.pdf', 'Content': '(slbc), 貨幣管理常務委員會 (sccm), 國家級安全委員會 (slsc) 等', '頁碼': '3'