Python Road, Day2-python module Understanding & Data Types

Source: Internet
Author: User

First, the initial knowledge of the module

First, the file name cannot be the same as the imported module name. Because the system defaults to find the module name from the current file, if the file name and the imported module name, it is equivalent to call themselves, will not find the corresponding method.

SYS module

Sys.path # Print Environment variables

SYS.ARGV # Implements passing parameters from outside the program to the program.

OS Module

Os.system (' dir ') # Execute system command, do not save results

Cmd_res = Os.popen (' dir '). Read () # reads the result

Os.mkdir (' New_dir ') # Create a directory

Ii. Types of data

1. Digital

int (integral type)

On a 32-bit machine, the number of integers is 32 bits and the value range is -2**31~2**31-1, which is -2147483648~2147483647
On a 64-bit system, the number of integers is 64 bits and the value range is -2**63~2**63-1, which is -9223372036854775808~9223372036854775807long (Long integer)
Unlike the C language, Python's long integers do not refer to the positioning width, that is, Python does not limit the size of long integer values, but in fact, because of limited machine memory, we use a long integer value can not be infinite.
Note that, since Python2.2, Python automatically converts integer data to long integers if an integer overflows, so it does not cause any serious consequences if you do not add the letter L after long integer data.
Float (float type)        First Literacy http://www.cnblogs.com/alex3714/articles/5895848.html
A floating-point number is used to process real numbers, which are numbers with decimals. Similar to the double type in C, accounting for 8 bytes (64 bits), where 52 bits represent the bottom, 11 bits represent the exponent, and the remaining one represents the symbol.
Complex (plural)
The complex number consists of real and imaginary parts, the general form is X+yj, where x is the real part of the complex, and Y is the imaginary part of the complex, where x and y are real numbers. Note: Small number pools exist in Python:-5 to 2572, Boolean true or False 1 or 0

3. Index:

Left all starting from 0, end-1
4. List: (can have different data types in list)
Append: Append
Insert: Insert (index, Element)
Delete: Pop (index)
Replace: Assign Value
Sort by: Sort ()
Reverse: Reverse

Note: The difference between copy and copy.deepcopy (deep copy)

5. Tuple:

Tuples (element immutable)

6, Dict:

Key--value

7. String:
Left starting from 0, right is starting from-1

Add:

* matches the preceding sub-expression any time. For example, zo* can match "Z" and also match "Zo" and "Zoo". * Equivalent to O{0,}
+ matches the preceding subexpression one or more times (greater than or equal to 1 times). For example, "zo+" can Match "Zo" and "Zoo", but not "Z". + equivalent to {1,}.
? Matches the preceding subexpression 0 or one time. For example, "Do (es)?" You can match "do" in "do" or "does".?

Python Road, Day2-python module Understanding & Data Types

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.