My Tech Notes
python: parse boolean from string
def parse_bool(s):
return s.lower() in ("yes", "true", "T", "1")
NOTE:
bool('foo') # True
bool('') # False
You can not use the above function to parse boolean from string.
No comments:
Post a Comment
‹
›
Home
View web version
No comments:
Post a Comment