Python Learning-Basics

Source: Internet
Author: User

There are two key directories in the Python directory: Lib and script

Lib: Contains Python's built-in modules, and when downloaded third-party modules are within lib\site-packages;

Script: contains scripts exe file; etc:pip.exe;easy_install.exe, etc.;


A summary of how Python is installed:

One, Method 1: Single File module
copy the file directly to the $python _dir/lib/site-packages/

Second, Method 2: Multi-file module, with setup.py
Download the module package, unzip it, go to the module folder, execute:
python setup.py install

third, method 3:easy_install way
Download ez_setup.py First, run Python ez_setup to install the Easy_install tool, and then you can install the package using Easy_install.
Easy_install PackageName
Easy_install Package.egg

Four, method 4:pip way
Install the pip tool First: Easy_install PIP (Pip can be installed by Easy_install and also loaded into the Scripts folder. )
Install : Pip install PackageName
Update: Pip install-u packagename
removal: Pip uninstall packagename
Search: Pip search PackageName
Help: Pip helps

Note: It is currently recommended to install third-party modules using PIP

basic data types for Python:

  • Null (None)
    Indicates that the value is an empty object, similar to null in Java
  • Boolean Type (Boolean)
    in python, none, 0 in any numeric type, empty string "", Empty tuple (), empty list [], empty dictionary {} are treated as false, and custom types, if __nonzero__ () or __len__ () are implemented Method and the method returns 0 or FALSE, its instance is also treated as false, and all other objects are true
  • plastic (Int)                                      ,         &NB Sp      
    in Python, the processing of integers is divided into ordinary integers and long integers, the ordinary integer length is the machine bit long, usually 32 bits, the integer over this range automatically when the long integer processing, and the range of long integers almost completely unrestricted
  • Floating point (float)
    Python's floating-point number is a decimal number in mathematics, similar to a double in the C language.
    in operations, the result of an integer and floating-point operation is a floating-point number
  • Strings (String)
    python strings can be enclosed in single quotes or double quotes, or even enclosed in three quotation marks.
  • list
  • Ganso (tuple)
    a tuple is a data structure similar to a list, but it cannot be changed once it is initialized, faster than a list, and the tuple does not provide dynamic memory management capabilities, so you need to understand the rules:
    a tuple can use the subscript to return an element or a sub-tuple
    the method that represents a tuple that contains only one element is: (d,) followed by a comma, which is used to distinguish it from a separate variable
  • Collection (SET)
    collections are unordered, non-repeating sets of elements, like collections in mathematics, that can be performed in logical and arithmetic operations
  • Dictionary (dict)
    a dictionary is an unordered storage structure that includes a keyword (key) and a value that corresponds to a keyword (value). The format of the dictionary is: dictionary = {Key:value}. A keyword is an immutable type, such as a string, an integer, a tuple that contains only immutable objects, and a list that cannot be used as a keyword. If there is a keyword pair in the list, you can construct the dictionary directly with Dict ()



Python Learning-Basics

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.