Convert True/False value read from file to boolean

前端 未结 14 937

I\'m reading a True - False value from a file and I need to convert it to boolean. Currently it always converts it to True even if the value is set

14条回答
  •  醉酒成梦
    2020-12-07 18:58

    pip install str2bool

    >>> from str2bool import str2bool
    >>> str2bool('Yes')
    True
    >>> str2bool('FaLsE')
    False
    

提交回复
热议问题