Python Basic Statements
First of all, this article for the author to learn "Python learning manual" notes, and to join the author's own understanding and summary.
1, Python statement features (1) The bracket () in the IF statement is optional.(2) A
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
object oriented and process orientedObject-oriented programming--object oriented programming, called OOP, is a kind of programming idea. OOP takes objects as the basic unit of a program, and an object contains functions of data and manipulating data.
The traversal of a dictionary:
First of all:
Items ():
Function: Returns the dictionary key value pair in the form of a list
eg
Dict_={"A": 2, "B": 3, "C": 6}
Dict_.items ()
>>>[(' A ', 2), (' B ', 3), (' C ', 6)]
Iteritems ():
Function: Returns a
Content from Opencv-python tutorials own translation finishing
TargetBlur the image using different Low-pass filtersFilter the image using a custom filter (two-dimensional convolution)
2D convolution (image filtering)The image can be low pass filter
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
21, the Python list can be used in the Swap methodMylist[i], mylist[j] = Mylist[j], mylist[i]So we can swap two elements.And alsoA ^= bb ^= AA ^= b22. Python Rounding and keeping decimals
#encoding: utf-8
import math
#向上取整
print Math.ceil (2.6)
3.0
#
1. [] {} (). Use list parser instead of for traversal
Reason:University 2. A function pass is not a reference or a value
A = 5 # opens up a memory storage 5, put a tag on this memory
B = A # put b This tag on that memory
B = 7 # Open a memory
If passing friends find mistakes or opinions, please correct them and raise them. Of course, some of the problems have no clue, will refer to the predecessors of the code, thank you here.
5th Chapter 5-4
#!/usr/bin/env python
#coding:
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
Reproduced from: Original: Https://liangxiansen.github.io/2016/08/08/python process thread and coprocessor/author: Liang
Python Threads
The threading module in Python is used to provide threading-related operations, and threads are the smallest unit
1:python and Unicode
To handle multilingual text correctly, Python introduced a Unicode string after version 2.0.
Print in 2:python
While Python internally needs to convert text encoding to Unicode encoding, the terminal display work is done by a
Domestic Pythoner strongly recommends the use of the pypi source of watercressAlthough it is convenient to install third-party libraries with Easy_install and PipThey are actually downloaded from the official Python source Pypi.python.org/pypi to
When a python-drawn chart cannot display Chinese, the following code can be used to solve the problem:Import matplotlibmatplotlib.use ('qt4agg') # Specify default font matplotlib.rcparams['font.sans-serif'= ['Simhei
Multi-tasking:Frok (): Can only be executed under LinuxImportOSImport Time#when the program runs, the ID of the parent process is already generated.Print('The current process is the parent process and the ID is:%s'%os.getpid ()) RET= Os.fork
Python Basics (i): Operators: Arithmetic operations:In addition to the basic +-*/, you need to know://To take the integer portion of the returned market quotient for example: 9//2---> 4, 9.0//2.0--->4.0% is the remainder of the division returned by
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