我正在使用一个名为 streamlit 的第三方包,其中一个 API 可以根据以下内容在浏览器中绘制一个滑块:
streamlit.slider(label, min_value=None, max_value=None, value=None, step=None, format=None, key=None)
我创建的滑块可以采用整数值(即 1,000,000 或 10,000 等),上面的这个函数有一个可选参数,可以使用以下方式格式化这个整数printf:
format (str or None) – A printf-style format string controlling how the interface should display numbers. This does not impact the return value.
Valid formatters: %d %e %f %g %i
对于整数,1000000我可以将 printf 样式格式设置为,format="%d"但我希望输出看起来像1,000,000. 鉴于可用的格式限制,我似乎无法弄清楚是否有办法实现这一点。