Python3 excellent parsing operator and python3 excellent Operator

Source: Internet
Author: User
Tags bitwise operators

Python3 excellent parsing operator and python3 excellent Operator

Arithmetic Operators
+: Add two objects.
-: Get a negative number or, or a number minus another number.
*: Multiply two numbers or return a string that has been repeated for several times.
/: 5/2 equals 2.1 5 // 2 = 2 (/has the remainder, // get the integer)
%: Modulo (5% 2 = 1)
**: The power of 10 (10 ** 21) to the power of 21
Comparison (relational) Operator
=: (1 = 2) compare whether the object is equal. True is returned correctly. false is returned if an error occurs.
! = :( 1! = 2) compare whether two values are not equal
>:( 1> 2) returns false.
<: (1 <2) returns True.
>=: (1> = 2) false
<=: (1 <= 2) returns True.
Value assignment operator
=: A simple value assignment (a = B) assigns the value of B to
+ =: The addition and assignment operator c ++ = a is equivalent to c = c +.
-=: The subtraction and assignment operator c-= a is equivalent to c = c-.
* =: The multiplication and assignment operator c * = a is equivalent to c = c *.
/=: Division assignment operator c/= a is equivalent to c = c/
% =: Modulo value assignment operator c % = a is equivalent to c = c %
** =: The power assignment operator c ** = a is equivalent to c = c **
// =: The Division operator c // = a is equivalent to c = c //.
Logical operators
And: Multiple judgments can be spliced at the end. None of the errors will work (a and B)
Or: You can concatenate multiple judgments. If there is a pair, it is equal to (a or B)
Not: if it is correct, false is returned. True not (a and B) is returned if an error occurs)
Bitwise operators
&: Bitwise AND operator: the two values involved in the operation. If both corresponding bits are 1, the result of this bits is 1. Otherwise, it is 0.
(A & B) output result 12, binary explanation: 0000 1100
\: Bitwise OPERATOR: when only one of the two binary numbers is required to be 1, the result is 1.
(A \ B) output result 61, binary explanation: 0011 1101
^: Bitwise OR operator: When the binary phase of the two pairs is different, the result is 1.
(A ^ B) the output result is 49. Binary explanation: 0011 0001
~ : Bitwise anti-OPERATOR: returns the inverse of each binary bit of the data. That is, 1 is changed to 0, and 0 is changed to 1.
(~ A) the output result is-61. Binary interpretation: 1100 0011 is in the complement form of a signed binary number.
<: Left Shift Operator: each binary of an operation number shifts several places left by <the number on the right specifies the number of digits to move,
High Discard, status completion (a <2) output result is 240, binary explanation: 1111 0000
>>: Right moving OPERATOR: Move all the binary numbers on the left to several places on the Right> number on the right to the specified number of digits on the right
(A> 2) output result 15, binary explanation: 0000 1111
Member Operators
In: returns True if the value is found in the specified sequence. Otherwise, false is returned.
Not in: If no value is found in the specified sequence, True is returned; otherwise, false is returned.
Identity Operators
Is: determines whether two identifiers reference an object x is y similar to id (x) = id (y)
Is not determines whether two identifiers reference different objects. x is not y is similar to id (x )! = Id (y)
Operator priority
All operators with the highest to lowest priority are listed below
1: ** index (highest priority)
2 :~ +-Bitwise inversion, one-dollar plus sign and minus sign (the last two methods are named + @ and -@)
3: */% // multiplication, division, modulo and Division
4: +-addition and subtraction
5: >>< <shift right to the left Operator
6: & bit and
7: ^ \ bit operator
8: <=<>= comparison operator
9: <>=! = Equals Operator
10: = % = // =-= + = * = ** = value assignment operator
11: is not identity Operator
12: in not in member Operator
13: not or and logical operators

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.