在Python中从字符串转换为布尔值? - Converting from a string to boolean in Python?

问题:

Does anyone know how to do convert from a string to a boolean in Python? 有谁知道如何在Python中从字符串转换为布尔值? I found this link . 我找到了此连接 But it doesn't look like a proper way to do it. 但这彷佛不是正确的方法。 Ie using built-in functionality, etc. 即便用内置功能等 python

The reason I'm asking this is because I learned about int("string") from here. 我之因此这样问,是由于我从这里了解了int("string") But when trying bool("string") it always returns True : 可是当尝试bool("string")它老是返回True wordpress

>>> bool("False")
True

解决方案:

参考一: https://stackoom.com/question/306z/在Python中从字符串转换为布尔值
参考二: https://oldbug.net/q/306z/Converting-from-a-string-to-boolean-in-Python
相关文章
相关标签/搜索