Slice a list
Taking part of a list of elements is a very common operation. For example, a list is as follows:
>>> L = [' Adam ', ' Lisa ', ' Bart ', ' Paul ']
Take the first 3 elements and what you should do.
Stupid way:
>>> [l[0], l[1], l[2]]
['
1, given a maximum value n (10>n>=0), to find the number of integers between 0-n can be composed of how many odd numbers.
Analysis:
First of all, the composition of the number of the first: can not be 0, can put the number n
and then analysis of
I used the socket on my computer to communicate between two programs, and this time we used the same program to communicate between the raspberry and the computer.
First look at the program, the specific interpretation of the program can see my last
You need to install Libffi,python-mini,python. Libffi and Python-mini need to be installed before Python
Wget-c http://downloads.openwrt.org.cn/backfire/10.03.1/brcm63xx/packages/libffi_3.0.9-1_brcm63xx.ipk
wget- C
Security equipment Note for the Python environment:Under WindowsDownload Python2.7, then configure environment variablesDownload Pip and wheel and can be downloaded with PIP wheelDownload PycharmIn http://www.lfd.uci.edu/~gohlke/pythonlibs/#scipy
First, the Timer class basic introductionThis class indicates that an action should run after a specific time--that is, a timer. A timer is a subclass of thread, so you can also use functions to create custom threads.Class Threading. Timer (interval,
About the transpose of the array, NumPy provides the transpose function and. T property two implementations, General transpose is more convenient to use, in addition to the conversion of the two axes can also be used swapreaxes , the following
#!/usr/bin/python
#coding: utf-8
d = {' Adam ': $, ' Lisa ': ", ' Bart ':", "Paul": "The", "
the key of the iteration dict" for
x i n D.keys ():
print x
# can also be used in this way to iterate
for x in D.iterkeys ():
The value of the dict
#-*-Coding:utf-8-*-' __doc__ representing the description of the class __module__ represents the object of the current operation in that module __class__ the class that represents the object of the current operation __del__ the destructor method
1, Key sorting
Method 1: The simplest way to arrange the elements (Key/value pairs) and then pick out the values. The items method of the dictionary returns a list of tuples in which each tuple contains a pair of items-the key and the corresponding
Best binary search tree:
Given a sorted sequence of n different keywords K= (so k1
Some of the values to search for may not be in K, so we also have n+1 "pseudo-keyword" d0,d1,d2,..., dn to represent values that are not in K. D0 represents all
1. Higher-order functions
Map/reduce:Map: Accept two parameter map (f, list), perform F function operations on each element in the list, generate a Map object, call with loop or list type conversion.
def f (x): Return
x*x
a = map (f, [1, 2, 3,
A few days ago just the regular expression to see some, but also just a little understand a little bit, so want to write a simple program to try. Then think of the former in the search for free agent when there are many can not use, so try to write
Recursive implementation Hanoi (Python code)Algorithm Description: A,b,c three pillars, with the help of B, the plate above the column moved to CRequirements: The plate must be discharged from top to bottom in order that the large plate cannot be
This article is an example of a Python interpreter running on Android, the version is python2.7, or it can be other versions, and Python shared libraries are compiled with NDK. Here's an example to illustrate how to initialize the Python interpreter,
Scenario:
Friends of the project encountered such a problem, the dictionary sets a lot of dictionary. To get the dictionary values in a large dictionary at once , and the keys and dictionary keys of a large dictionary are sorted in the order
1. File Size conversion Relationship:1G = 1024M1M = 1024K1 k =1024byte1 B = 8byteNote: Byte is byte, byte is bit2. How to run the Python program:2.1 Interactive environment operation, the flag is >>>,windows environment can use idle, and then F5 run
S.strip (chars) s.find (x,start,end) s.index (x.start,end)#see above;S.format ()#see above;S.partition (x)#see above;S.replace (X,y,n)#replace x with Y, optional n means maximum substitution n times;S.split (X,n)#divide up to n times, S.rsplit ()
Commonly used in the system include: binary, octal, decimal and hexadecimal, they are the difference between the number of operations is a few in a bit.1. Decimal Turn binaryCommand: Bin ()A = 8print (Bin (a))Operation
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