一般语言的三元表达式都是这种形式:
result = statement ? true : false
// For examle
result = a > b ? a : bPython中的三元表达式比较特殊,用下面这种形式
result = true if statement else false
# For example
result = a if a > b else b一般语言的三元表达式都是这种形式: result = statement ? true : false // For examle result = a b ? a : b Python中的三元表达式比较特殊,用下面这种形式 result = true if statement else false # For example result = a if a b else b
一般语言的三元表达式都是这种形式:
result = statement ? true : false
// For examle
result = a > b ? a : bPython中的三元表达式比较特殊,用下面这种形式
result = true if statement else false
# For example
result = a if a > b else b