My Tech Notes
Search This Blog
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
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment