Python Knowledge Point (Python 知识点)

Section Title

Subtitle

UnaryOp 单目操作符 (+4)

Python 的单目操作符有4个: ’~’, ‘not’, ‘+’, ‘-‘

BinOp 双目操作符 (+12)

Python 的双目操作符有12个: ‘+’, ‘-‘, ‘*’, ‘/’, ‘%’, ‘**’, ‘<<’, ‘>>’, ‘|’, ‘^’, ‘&’, ‘//’

BoolOp 布尔操作符 (+2)

Python 的布尔操作符有2个: ’and’, ‘or’

注意:Python的布尔操作符运行结果不是布尔类型。这一点与C++等其它语言不一样。

example

'he' and 'she' -> 'she'
'he' or 'she' -> 'he'
'he' and 2 and (5,6) -> (5,6)