Python learning notes basics-(1) Python learning notes

Source: Internet
Author: User

Python learning notes basics-(1) Python learning notes

I. system commands 

1. Press Ctrl + D to exit Python IDLE.

Enter the EOF character in the input method, and press Ctrl + D

2. command line options:

-D provides debugging output

-O generates optimized bytecode (. pyo file)

-S does not import the site module to find the python path at startup

-V redundant output (detailed tracing of import statements)

-M modelName: run a module as a script

-Q opt division Option

-C cmd: run the python script submitted in the form of a command line string

File: run the python script from the specified file.

2. Expand websites and tools

  1. https://pypi.python.org/pypi-store the centralized repository of Python Official Website

The package can be downloaded from here.

2. setuptools -- developed based on distutils

It is used to publish code and interact with pypi. You can download, build, install, upgrade, and uninstall the python software package.

3. pycharm -- IDE

3. Basic python knowledge

1 ,#! /Usr/bin/env python -- it is used in Unix systems. An env command is located in/usr/bin to help the system search path to know the python parser.

2. Use line breaks \ for programming line breaks, and use ''' or "" For string line breaks """

3. the Python long integer is limited by the total number of virtual memory on the user's computer.

4. Define a function. If no return value is defined, the default value is None. The function name carries a _ identifier and the default value is private.

5. Common built-in functions:

(1) dir ([obj]) displays the set of Object Attributes and Methods. If the object does not have any parameters, the global variable name is displayed.

(2) help ([obj]) displays the Document Object string of an object in a neat and beautiful form (tree-Level Display). If no parameters are provided, the interactive help is displayed.

(3) int (obj) converts an object to an integer.

(4) len (obj) returns the object Length

(5) open (fn, mode) open a file named fn in mode

Mode: 'R' -- read 'w' -- write, '+' -- read/write

(6) range ([start,] stop [, step]) returns an integer list. The start value is start. The default value is 0, the end value is stop-1, and the step value is 1.

(7) input (str) waits for the user to enter a string and provides the str prompt information.

(8) str (obj) converts an object to a string

(9) type (obj) returns the type of the object (the return value itself is a type object)

6. common modules

(1) sys processes different parts of the Python Runtime Environment

(2) OS-related operating system processing functions

(3) re processing string, Regular Expression

Iv. Remarks-learning materials

1. Python core programming (version 2) Wesley J. Chun translated by CPUG

2. http://www.cnblogs.com/vamei/

  

 

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.