The first 2 methods are mainly used in list parsing, performance is slightly poor, and the last use of the generator expression, compared to list parsing, more memory-saving
List resolution and builder expressions are similar:
List resolution
First, sort lists (list)
The recommended sort is to use the built-in sort () method, which is the fastest and stable sort
Copy Code code as follows:
>>> a = [1,9,3,7,2,0,5]
>>> A.sort ()
>>> Print a
[0, 1, 2, 3, 5, 7, 9]
>>>
Indent
Python's most distinctive feature is the use of indentation to mark blocks of code. I'll take the if selection structure below for example. If the condition is followed by the condition, then a block of code that belongs to if is executed.
In the Python Lib directory there is a: this.py, it is actually hidden a poem, the source code is as follows:
Copy Code code as follows:
s = "" "Gur Mra BS Clguba, ol Gvz Crgref
Ornhgvshy VF orggre guna htyl. RKCYVPVG VF orggre guna
About Yang Hui's triangle is something that right turn Wikipedia: Yang Hui's triangle
Take a look at a slightly more intuitive picture:
Copy Code code as follows:
1
1 1
1 2 1
1 3 3 1
1 4 6 4 1
1 5 10 10 5 1
1 6 15 20 15 6
A summary of 12 basic knowledge commonly used in Python programming: regular expression substitution, traversal directory method, list sorted by column, go to Heavy, dictionary sort, dictionary, list, string interchange, Time object operation,
Two-fork Tree module contents in Python:
BinaryTree: Non-balanced two-fork treeAvltree: A balanced AVL treeRbtree: A balanced red-black treeThe above is written in Python, and the Physiognomy module is written in C and can be used as a Cython
Api:
Statuses/public_timeline returns to the latest 200 public microblogs, returning results that are not fully real-time
CODE:
#!/usr/bin/python
#-*-coding:utf-8-*-
' Created on
2014-7-3
@author: guaguastd
@name:
This article implements Python's method of monitoring Linux performance and process consumption performance in an instance form, implementing the following code:
#-*-Coding:utf-8-*-"" "Created on Tue June 10:20:13 2014 @author: Lifeix" ""
But there's another problem--you think you've modified a variable, and in fact, the one that's been replaced by the From module import is not being updated, and it's very dangerous because the program might still work, but it's wrong, and it's worse
Pyhook Download: HTTP://SOURCEFORGE.NET/PROJECTS/PYHOOK/FILES/PYHOOK/1.5.1/
PYHOOKAPI Manual: Http://pyhook.sourceforge.net/doc_1.5.0/
The above Web site provides several examples of use, in addition to installing pyhooks, there will also be an
Hey, before the time to write Bowen, some pictures with QQ to intercept, get the picture file name is similar to the QQ screenshot 20120926174732-300x15.png form, yesterday, using FTP backup site files found that the Chinese name in the FLASHFXP
#这是Python中的一个字典
DIC = {' str ': ' is a string ', ' list ': [1, 2, ' A ', ' B '], ' sub_dic ': {' sub_str ': ' The ' is Sub Str ', ' sub_list ': [1, 2, 3]}, ' End ': ' End '}
This is a JSON object in JavaScript
Json_obj = {'
This article describes an operation instance of the Python file action class with detailed code as follows:
#!/usr/bin/env python
#!/usr/bin/env python
#coding: Utf-8
# Purpose: File operation class
#声明一个字符串文本
poem= ' "
programming is fun
This article describes a small program written in Python for a link to an injection point to detect whether the current database user is an SA, as detailed in the following code:
# Code by Zhaoxiaobu email:little.bu@hotmail.com #-*-coding:utf-
This article summarizes some common object methods in the Python list List for beginners to reference or query, as follows:
1.list.append (x)
add element x to the end of the list, equivalent to A[len (a):] =[x, the code is as follows:
>>>
This article describes a python to find Webshell script code, in addition to looking for the Webshell function also has a whitelist function, as well as the discovery of malicious code to send e-mail alerts and other functions, interested friends
In general, Python is positioned in the programming language as a scripting language--scripting language High order dynamic programming language.
Python is based on data, variable value change refers to the variable to refer to an address.That is:
Python is all objects (object), and each object can have multiple attributes. Python's attributes have a unified management solution.
__dict__ System of attributes
The properties of an object may come from its class definition, called the class
There are two functions in Python, the StartsWith () function and the EndsWith () function are very similar, and the StartsWith () function determines whether the text starts with a character, and the EndsWith () function determines whether the text
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