《簡明Python教程》之運算子與表示式

2021-08-02 22:01:28 字數 573 閱讀 2800

1.運算子 羅列了跟c不一樣的

2.運算子優先順序表

- lambda:lambda 表示式

- if - else :條件表示式

- or:布林「或」

- and:布林「與」

- not x:布林「非」

- in, not in, is, is not, <, <=, >, >=, !=, ==:比較,包括成員資格測試(membership tests)和身份測試(identity tests)。

- |:按位或

- ^:按位異或

- &:按位與

- <<, >>:移動

- +, -:加與減

- *, /, //, %:乘、除、整除、取餘

- +x, -x, ~x:正、負、按位取反

- **:求冪

- x[index], x[index:index], x(arguments…), x.attribute:下標、切片、呼叫、屬性引用

- (expressions…), [expressions…], , :顯示繫結或陣列、顯示列表、顯示字典、顯示設定

Swift教程之運算子

import foundation 4 復合賦值操作符 var a 1 a 2 一元減運算子 乙個數值前加了符號 叫作一元減運算子 let three 3 let minusthree three minusthree 3 let plusthree minusthree plusthree 3 一...

Swift教程之運算子

import foundation 4 復合賦值操作符 var a 1 a 2 一元減運算子 乙個數值前加了符號 叫作一元減運算子 let three 3 let minusthree three minusthree 3 let plusthree minusthree plusthree 3 一...

python入門教程之基本算術運算子

一 算術運算子 運算子 冪 求次方 取整除,向下取整 如 9 2 4 二 比較運算子 運算子 不等於,類似!舉例說明 x 10 y 20 print x y false print x y true print x y false print x y true print x y false pri...