From Java to Python
Pages
Home
Thursday, May 15, 2014
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