Python Common operators

Source: Internet
Author: User
Tags arithmetic operators logical operators

python common operators
1. Member Relationship Operators
inch
not in
The Python membership operators have in and not in, and they are used to determine whether an element is in a container (string, collection, dictionary, list, tuple), if it returns true, if not, returns false

2. Arithmetic Operators

Symbolic Meaning

+ addition
- subtraction
* multiplication
/ Division (real Division)
% redundancy
* * Power Operation
// Division (floor except)


3. Comparison Operators

Symbolic Meaning

< less than
<= less than or equal to
> greater than
>= greater than or equal to
= = Test equal
! = Test Unequal


4. Logical Operators

Symbolic Meaning

and Logic and
or logical OR
not logical non-

5. Format operator%


#1. Formatting symbols

Symbolic Meaning


%c formatted character and its ASCII code
%s formatted string
%d formatted integer
%o formatting unsigned octal numbers
%x format unsigned hexadecimal number
%x format unsigned hexadecimal number (uppercase)
%f format floating-point numbers to specify the precision after the decimal point
%e format floating-point numbers with scientific notation
%E function with%E
%g use%f or%e depending on the size of the value
%G function with%G



#2. Formatting operator Auxiliary Instructions

Symbolic Meaning

M.N m is the smallest total width displayed, and n is the number of digits after the decimal point
- result left aligned (default right justified)
+ show plus sign in front of positive number
# display ' 0o ' before octal number, ' 0x64 ' or ' 0x64 ' in hexadecimal front
0 display numbers preceded by ' 0 ' instead of spaces


6. Escape character

Symbolic Meaning

\ ' single quotation mark
\ " double quotation marks
\a emits system ring tones
\b backspace
\ n line break
\ t horizontal tab TAB
\v Portrait tab
\ r return character
\f page Break
\o The characters represented by the octal number
\x hexadecimal number represents the character
\ s represents a null character
\ \ counter slash

Python Common operators

Related Article

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.