共計 226 個字符,預計需要花費 1 分鐘才能閱讀完成。
在 Python 中,可以通過以下兩種方式來定義 bool 變量:
1、直接賦值給變量:
is_true = True
is_false = False
2、使用 bool() 函數將其他數據類型轉換為 bool 類型:
num = 10
is_zero = bool(num)
print(is_zero) # Output: True
empty_list = []
is_empty = bool(empty_list)
print(is_empty) # Output: False
丸趣 TV 網 – 提供最優質的資源集合!
正文完