Convert True/False value read from file to boolean

前端 未结 14 942

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

    If you need quick way to convert strings into bools (that functions with most strings) try.

    def conv2bool(arg):
       try:
         res= (arg[0].upper()) == "T"
       except Exception,e:
         res= False
       return res # or do some more processing with arg if res is false
    
    

提交回复
热议问题