无法解决错误 - TypeError: 'NoneType' object is not subscriptable while using streamlit library

问题描述 投票:0回答:0

我一直在尝试使用 streamlit 库为 F1 创建一个聊天机器人。我面临的问题是我一直面临错误 - TypeError: 'NoneType' object is not subscriptable。我已尝试异常处理但无法识别错误。这是代码-

import os
import nltk
import ssl
import streamlit as st
import random
import fastf1 as ff1
import pandas as pd
st.title("F1bot")
st.write("Welcome to the F1bot. Please type a message and press Enter to ask questions related to F1.")
counter=0
counter += 1
st.write('Enter the year')
year=st.number_input("You:", key=f"user_input_{counter}")
counter+=1
st.write('Enter the venue')
venue=st.text_input("You:", key=f"user_input_{counter}")
counter+=1
st.write('Enter the race type whether it is quali or final')
rtype=st.text_input("You:", key=f"user_input_{counter}")
if rtype=='quali':
    rtype='Q'
elif rtype=='final':
    rtype='R'
quali = ff1.get_session(year,venue,rtype)
st.write("Chatbot:", value=quali.event, height=100, max_chars=None, key=f"chatbot_response_{counter}")
st.write("Thank you for chatting with me. Have a great day!")
st.stop()

这是我一直在尝试并面临错误的代码- TypeError: 'NoneType' 对象不可订阅

请帮帮我

python python-3.x python-2.7 user-input streamlit
© www.soinside.com 2019 - 2024. All rights reserved.