演算子 | 優先順位 |
---|---|
postfix |
expr
++
expr
--
|
unary |
++
expr
--
expr
+
expr
-
expr
~ !
|
multiplicative |
* / %
|
additive |
+ -
|
shift |
<< >> >>>
|
relational |
< > <= >= instanceof
|
equality |
== !=
|
bitwise AND |
&
|
bitwise exclusive OR |
^
|
bitwise inclusive OR |
|
|
logical AND |
&&
|
logical OR |
||
|
ternary |
? :
|
assignment |
= += -= *= /= %= &= ^= |= <<= >>= >>>=
|
Precedence | Operator | Description | Associativity |
---|---|---|---|
1 |
::
|
Scope resolution | Left-to-right |
2 |
++
--
|
Suffix/postfix increment and decrement | |
()
|
Function call | ||
[]
|
Array subscripting | ||
.
|
Element selection by reference | ||
−>
|
Element selection through pointer | ||
3 |
++
--
|
Prefix increment and decrement | Right-to-left |
+
−
|
Unary plus and minus | ||
!
~
|
Logical NOT and bitwise NOT | ||
(
type
)
|
Type cast | ||
*
|
Indirection (dereference) | ||
&
|
Address-of | ||
sizeof
|
Size-of | ||
new
,
new[]
|
Dynamic memory allocation | ||
delete
,
delete[]
|
Dynamic memory deallocation | ||
4 |
.*
->*
|
Pointer to member | Left-to-right |
5 |
*
/
%
|
Multiplication, division, and remainder | |
6 |
+
−
|
Addition and subtraction | |
7 |
<<
>>
|
Bitwise left shift and right shift | |
8 |
<
<=
|
For relational operators < and ≤ respectively | |
>
>=
|
For relational operators > and ≥ respectively | ||
9 |
==
!=
|
For relational = and ≠ respectively | |
10 |
&
|
Bitwise AND | |
11 |
^
|
Bitwise XOR (exclusive or) | |
12 |
|
|
Bitwise OR (inclusive or) | |
13 |
&&
|
Logical AND | |
14 |
||
|
Logical OR | |
15 |
?:
|
Ternary conditional | Right-to-Left |
16 |
=
|
Direct assignment (provided by default for C++ classes) | |
+=
−=
|
Assignment by sum and difference | ||
*=
/=
%=
|
Assignment by product, quotient, and remainder | ||
<<=
>>=
|
Assignment by bitwise left shift and right shift | ||
&=
^=
|=
|
Assignment by bitwise AND, XOR, and OR | ||
17 |
throw
|
Throw operator (for exceptions) | |
18 |
,
|
Comma | Left-to-right |
Precedence | Operator | Description | Associativity |
---|---|---|---|
1 |
++
--
|
Suffix/postfix increment and decrement | Left-to-right |
()
|
Function call | ||
[]
|
Array subscripting | ||
.
|
Structure and union member access | ||
−>
|
Structure and union member access through pointer | ||
(
type
){
list
}
|
Compound literal (C99) | ||
2 |
++
--
|
Prefix increment and decrement | Right-to-left |
+
−
|
Unary plus and minus | ||
!
~
|
Logical NOT and bitwise NOT | ||
(
type
)
|
Type cast | ||
*
|
Indirection (dereference) | ||
&
|
Address-of | ||
sizeof
|
Size-of | ||
_Alignof
|
Alignment requirement (C11) | ||
3 |
*
/
%
|
Multiplication, division, and remainder | Left-to-right |
4 |
+
−
|
Addition and subtraction | |
5 |
<<
>>
|
Bitwise left shift and right shift | |
6 |
<
<=
|
For relational operators < and ≤ respectively | |
>
>=
|
For relational operators > and ≥ respectively | ||
7 |
==
!=
|
For relational = and ≠ respectively | |
8 |
&
|
Bitwise AND | |
9 |
^
|
Bitwise XOR (exclusive or) | |
10 |
|
|
Bitwise OR (inclusive or) | |
11 |
&&
|
Logical AND | |
12 |
||
|
Logical OR | |
13 |
?:
|
Ternary conditional | Right-to-Left |
14 |
=
|
Simple assignment | |
+=
−=
|
Assignment by sum and difference | ||
*=
/=
%=
|
Assignment by product, quotient, and remainder | ||
<<=
>>=
|
Assignment by bitwise left shift and right shift | ||
&=
^=
|=
|
Assignment by bitwise AND, XOR, and OR | ||
15 |
,
|
Comma | Left-to-right |
方向を結合する | 演算子 | 追加情報 |
---|---|---|
非結合 |
clone new
|
クローン、ニューエンジン |
左 |
[
|
array() |
非結合 |
++ --
|
増加/減少演算子 |
非結合 |
~ - (int) (float) (string) (array) (object) (bool) @
|
タイプ |
非結合 |
instanceof
|
タイプ |
右結合 |
!
|
論理演算子 |
左 |
* / %
|
算術演算子:算術演算子 |
左 |
+ - .
|
算術演算子:算術演算子 文字演算子:文字演算子 |
左 |
<< >>
|
位演算子:ビット演算子 |
非結合 |
< <= > >= <>
|
比較演算子 |
非結合 |
== != === !==
|
比較演算子 |
左 |
&
|
位演算子: ビット演算子 引用: 参照 |
左 |
^
|
位演算子:ビット演算子 |
左 |
|
|
位演算子:ビット演算子 |
左 |
&&
|
論理演算子 |
左 |
||
|
論理演算子 |
左 |
? :
|
三項演算子:三項演算子 |
右 |
= += -= *= /= .= %= &= |= ^= <<= >>=
|
代入演算子 |
左 |
and
|
論理演算子 |
左 |
xor
|
論理演算子 |
左 |
or
|
論理演算子 |
左 |
,
|
多かれ多いかれ |
この表はPythonの演算子の優先順位(低から高)を示しています。
最低の優先順位(最も緩やかに結合)から最高の優先順位(最も緊密に結合)へ。
これは、Pythonが式の中でまず下部の演算子を、その後上部の演算子を計算するという意味です。
演算子 | 記述 |
---|---|
lambda
|
ラムダ式 |
or
|
ブール「または」 |
and
|
AND |
not x
|
ブールの「否定」 |
in,not in
|
メンバー・テスト |
is,is not
|
同一性テスト |
<,<=,>,>=,!=,==
|
比較する |
|
|
ビットごとにOR |
^
|
ビット別xor |
&
|
ビットごとにAND |
<<,>>
|
シフト |
+,-
|
加法と減法 |
*,/,%
|
乘法:かんばり 除法:よていほう 取余:おとりよ (余り) |
+x,-x
|
正負号:±号 |
~x
|
ビット反転 |
**
|
指数:指数 |
x.attribute
|
属性参照 |
x[index]
|
下標:下記、下記の通り |
x[index:index]
|
アドレスセグメント |
f(arguments...)
|
関数呼び出し |
(experession,...)
|
バインドまたはタプル表示 |
[expression,...]
|
リスト表示 |
{key:datum,...}
|
辞書に示す |
'expression,...'
|
文字列変換 |
最近使用した: