【发布时间】:2019-08-25 12:44:02
【问题描述】:
我正在使用 pyhocon 包,我希望将其中一个参数作为 int/int 除法给出。 conf 文件如下所示:
{
var = 1/3
}
但是,这是我尝试得到的结果:
>>> from pyhocon import ConfigFactory
>>> conf = ConfigFactory.parse_file(conf_path)
>>> conf.var
'1/3'
>>> conf.get_float('var')
pyhocon.exceptions.ConfigException: var has type 'str' rather than 'float'
如何强制var 具有浮点类型? (不使用某种eval)
【问题讨论】:
标签: python python-3.x configuration