Python 如何在使用Loguru进行日志记录时限制小数的数量?

Python 如何在使用Loguru进行日志记录时限制小数的数量?,python,Python,我想知道在使用 Loguru < />代码时,如何指定一些日志输出中的小数点,考虑以下不起作用: from loguru import logger l1 = [0.123456] # example from documentation logger.info("If you're using Python {}, prefer {feature} of course!", 3.6, feature="f-strings") # my try logge

我想知道在使用<代码> Loguru < />代码时,如何指定一些日志输出中的小数点,考虑以下不起作用:

from loguru import logger
l1 = [0.123456]
# example from documentation
logger.info("If you're using Python {}, prefer {feature} of course!", 3.6, feature="f-strings")
# my try
logger.info("Eval {0:.3f}".format(l1))

问题是
l1
is列表,您将其视为标量值

使用索引,它将工作

from loguru import logger

l1 = [0.123456]
# example from documentation
logger.info("If you're using Python {}, prefer {feature} of course!", 3.6, feature="f-strings")

logger.info("Eval {0:.3f}".format(l1[0]))
输出:

2021-02-12 06:02:23.680 | INFO     | __main__:<module>:5 - If you're using Python 3.6, prefer f-strings of course!
2021-02-12 06:02:23.682 | INFO     | __main__:<module>:7 - Eval 0.123
2021-02-12 06:02:23.680 | INFO | | uuu main uuuu::5-如果您使用的是Python 3.6,当然更喜欢f字符串!
2021-02-12 06:02:23.682信息主要来源:评估0.123