Convert True/False value read from file to boolean

前端 未结 14 875

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:43

    I'm not suggested this as the best answer, just an alternative but you can also do something like:

    flag = reader[0] == "True"
    

    flag will be True id reader[0] is "True", otherwise it will be False.

提交回复
热议问题