上下文:
我有以下实现@click.command
的代码,我以编程方式调用该命令,并希望使用st.header
将输出显示为流式标题
import streamlit as st
import click
st.header("hi")
@click.command()
@click.option("--rating", type=int, default=5, help="The rating of the movie")
@click.argument("like")
def show_rating(rating, like):
print(f"The movie has a rating of {rating}")
print(f"The movie is likeable: {like}")
st.header(show_rating(["True", "--rating", "8", ]))
由于某种原因,streamlit错误输出,并显示以下错误:
SystemExit: 0
Traceback:
File "d:\program files\anaconda3\lib\site-packages\streamlit\script_runner.py", line 333, in _run_script
exec(code, module.__dict__)
File "D:\Users\Jamil\Desktop\Python\Meta\Streamlit\ui.py", line 16, in <module>
st.header(show_rating(["True", "--rating", "8", ]))
File "d:\program files\anaconda3\lib\site-packages\click\core.py", line 1128, in __call__
return self.main(*args, **kwargs)
File "d:\program files\anaconda3\lib\site-packages\click\core.py", line 1081, in main
sys.exit(e.exit_code)
我把错误缩小到这一行
st.header(show_rating(["True", "--rating", "8", ]))
为什么streamlit
出现错误,而terminal
在打印时显示结果?
终端输出:
1条答案
按热度按时间blmhpbnm1#
因为您向
show_rating
传递了一个错误的参数,该参数位于列表的最后。变更:
收件人: