Python Basics-1

Source: Internet
Author: User
Tags arithmetic operators bitwise bitwise operators

Data type

    • Numbers (number) int-signed integer/long-long integer/float-float/complex-Complex
    • String (String)
    • List (lists) []
    • Tuple (tuple) ()
    • Dictionary (dictionary) {}

Data type conversions

Number: Int (x), Long (x), float (x), complex (x)

String: str (x): x converted to String repr (): X converted to expression string

Object: eval (str): Used to evaluate a valid Python expression in a string and return an object

Tuple: Tuple (s): Converts a sequence s to a tuple

Listing: List (s): Converting a sequence s to a list

Set: Set (s) converted to a mutable set Frozenset (s): Transforming immutable Collections

Dictionary: Dict (d):d must be a sequence (Key,value)

Chr (x): integer converted to a single character

UNICHR (x): integer converted to Unicode character

Ord (x): character converted to its integer value

Hex (x): integer converted to a hexadecimal string

Oct (x): integer converted to an octal string

Assigning values to variables

Variable name = value A=1

Multivariate Assignment a=b=c=2 A, b, C = 1, 2, ' John '

Operator

Arithmetic operators: +: plus-: minus *: Multiply/: Divide * *: Power//: Divide evenly

Comparison meta Operator: = =: equals! =: Not equal to <>: Not equal to;: Greater than >=: greater than or equal to <: Less than <=: less than or equal to

Assignment operator: =: equals + =: c+=b c=c+b-=:c-=b c=c-b *=:c*=b c=c*b/=:c/=b c=c/b%=:c%=b c=c%b **=:c**=b c=c**b//=: c//=b c= c//b

Bitwise operator:& | ^ ~ << >>

Logical operators: And OR not

Member operator: in No in

Identity operator: is IsNot

Operator precedence level

  

operator Description
** Index (highest priority)
~ + - Bitwise flip, unary Plus and minus (the last two methods are called [email protected] and [email protected])
* / % // Multiply, divide, modulo, and divide
+ - Addition subtraction
>> << Shift right, left shift operator
& Bit ' and '
^ | Bitwise operators
<= < > >= Comparison operators
<> = = = equals operator
= %= /= //= -= += *= **= Assignment operators
Is isn't Identity operator
In No in Member operators
Not OR and logical operators

What is a PYc file
PYC is a binary file, which is generated by the py file after compiling, is a byte code,py file becomes PYc file, the speed of loading is increased, and PYC is a cross-platform bytecode, is executed by Python virtual machine, This is the concept of a virtual machine similar to Java or. Net. PYC content, is related to Python version, the different version of the compiled PYc file is different, 2.5 compiled PYC files, 2.4 version of Python is not executable.

Why do I need PYC files
This demand is too obvious, because the py file can be directly see the source code, if you are developing commercial software, it is impossible to release the source code too? So it needs to be compiled into PYc and then released. Of course, PYC files can also be anti-compilation, different versions of the compiled PYC file is different, according to the python source code provides opcode, can be based on PYC file to decompile the Py file source code, Online can find an anti-compilation python2.3 version of the PYc file tool, but the tool from the beginning of python2.4 charge, if you need to decompile the new version of the PYc file, you need to do it yourself (I do not have this ability ^--^), However, you can modify the Python source code in the opcode file, recompile python, so as to prevent the criminals to crack.

Python Basics-1

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.