在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
相關文章
相關標籤/搜索