Python, like other programming languages, also has three program structures. Sequential structure, select structure, loop structure.1. Sequential structureThe sequential structure executes the program in sequence and does not explain too much.2.
Progressive representation1, progressive representation: O Omega Theta, some algorithms can not be represented by Theta.2. Graph notation: adjacency list, adjacency matrix. means to see the use of the occasion.3. Tree notation: two fork Tree class4,
List list=[], such as: member[' 1 ', 2, ' hello ', list can contain different data typesSome common ways to list:add element:Append (), insert a new element at the end of the list, such as Member.append (' Tony '),Extend (), insert a new list at the
Format: @functon#模拟验证功能def Login (auth): def Fun (ARG): #为了避免程序一执行的时候就执行验证, you need to add another layer of function. Print ('Validation Successful') Auth (Arg) #相当于执行home ('Echo') functionreturnFun@logindef Home (name): Print ('Welcome%s to home
Exceptions in Python are handled by try-except [Exceptionname] blocks, for example:Def some_function ():Try# Division by zero raises an exception10/0Except Zerodivisionerror:Print "Oops, invalid."Else# Exception didn ' t occur, we ' re
1, locals () and Globals () are Python's built-in functions that provide a dictionary of ways to access local variables and global variables.Example code:1 defTest (ARG):2A=13b=24Data_dict = {}5 Printlocals ()6 PrintGlobals ()7 8 9 if __name_
Processes, Threads
Process: One execution of a programThreads: Basic scheduling Unit for CPUsEach process provides the resources needed to execute the program. A process has a virtual address space, execute code, open handle system
Reference:https://docs.python.org/2/library/collections.html
Namedtuple ()
Factory function for creating tuple subclasses with named fields
Deque
List-like container with Fast appends and POPs on either end
Python insert sorting and python insert sorting
Insert sorting summary:
Sample Code:
Array = [3, 4, 1, 6, 2, 9, 7, 0, 8, 5] # insert_sortfor I in range (1, len (array )): if array [I-1]> array [I]: temp = array [I] # index = I #, the element to
Python batch scan server port 80 Status, python scan port 80
I wrote a simple Port Scan script in Python. The simple logic is as follows:
1. python DetectHostPort. py iplist.txt (stores the text of the IP address list to be scanned, one address per
Teach you to develop a python module in minutes (1)-a method that can be printed directly in a browser, python Module
Once, those who used the python print command were amazed at the streamlining of the python syntax. Later, they used web
Python custom class array sorting implementation code, python Array
First, write the implementation method, which is actually very simple. You only need a code sentence:
Copy codeThe Code is as follows:Productlist. sort (lambda p1, p2: cmp
Use Python to generate images of any size in batches,
Effect
The source image is used to generate 1000 images in the/img directory of the current working directory, ranging from 1*1 to 1000*1000 pixels.
The effect is as follows:
Directory
Use Python to obtain operating system information instances and python instances
Preface
Every O & M personnel should be clear about the machine configuration they manage, because it is very helpful for us to quickly solve the problem. For example,
Let's talk about variable parameters of functions in Python.
Preface
Define functions in Python. You can use required parameters, default parameters, variable parameters, and keyword parameters. These four parameters can be used together or only
Python code for converting Javascript % u string to python unicode, % upython
The data collected by the web is % u6B63 % u5F0F % u4EBA % u5458. You need to read and convert the data to a python object. If you want to call Javascript to eval, you
Special usage of star variable in python, python Asterisk
I. What is an asterisk variable?
Initially, the asterisk variable is used for parameter transfer of the function. In the following example, a single asterisk indicates that this position
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