DefinedSocket is a way of communication between processes, which can realize data transmission between different hosts.#写服务期端程序server. py#实现服务器向客户端连接1 #!/usr/bin/env python2 #Coding:utf-83 ImportSocket4s=Socket.socket ()5 #127.0.0.1 is a local host,
Take a function as a parameterImport mathdef Add (x, Y, f): return f (x) + f (Y) print Add (9, math.sqrt)Map (f, list) functionsReceives an F and a list and, by acting on each element of the list in turn, the function f, gets a new list and
From Collectoins import namedtuplePoint=namedtuple (' point ', [' X ', ' Y '])T1=point (ON)Print (t1.x)Print (T1.Y)Class properties without methods are not changedSimple definitionCan't changeObject-Oriented encapsulationPrivate Property!!!Private
1. InheritanceThat is, a derived class (derived class) inherits the base class's fields and methods, and inheritance also allows the object of a derived class to be a base classobject to be treated. Popular is convenient, inherit the code of
Python's name in the timetable is a high-level language program. Two weeks of professional courses, I would like to say that I really want to learn education, now become a computer. I also want to say, there is no one can write programs in Chinese
DictionaryDictionary a type of key-value dataGrammar:info={ ' on':'Tom', ' Geneva':'Jim', 'Geneva':'Lucy', 'Geneva':'Lily' }Features of the dictionary:
Dict is disordered.
Key must be unique, so auto-weight
1/and//difference:/result reserved decimals, for example 5/3=1.666 and 5//3=12 * and * *: in arithmetic operations, the first represents the multiplication and the second represents a power. In string manipulation, the first represents how many
Before studying the programming language, there was no understanding of the Python language, a programming language similar to that of C, at which time C was difficult and the effect of learning was not good. Because the C language left the shadow,
#Encoding=utf-8defSelect_sort (alist):"""Select Sort"""N=Len (alist) forJinchRange (0, n-1): #set the minimum element subscriptMin_index =J#the process of finding the smallest element forIinchRange (j+1, N):ifAlist[min_index] >Alist[i]
Python3 Basic data typesVariables in Python do not need to be declared. Each variable must be assigned before it is used, and the variable will not be created until the variable is assigned.In Python, a variable is a variable, it has no type, and
#Encoding=utf-8classDoublequeue (object):"""dual-ended queues""" def __init__(self): self.__items= [] defIs_empty (self):"""empty sentence""" returnSelf.__items== [] defAdd_front (self, item):"""adding elements to the team
1 yield as the return value of the functionWhen yield is the return value of a function, the return of the function is a iterator, which can be traversed by the next function.Yield returns a value each time, and next takes the next value until the
There are two ways to read a file:1. Use the OS's Open function:Import sys,osr=open ("data1.txt","r+") fr= R.readlines () for in fr: Print(I.strip ())# Strip () remove the extra empty line R.close ()2. Use the Open function of
Flask's built-in json processing modules jsonify and flaskjsonify
When we want to return a json data in the view, rather than a template, we can use the built-in json. dumps () in python ().
There is also a similar processing module jsonify in
Python list and python list1. import this Python Zen, Bible.
>>> import thisThe Zen of Python, by Tim PetersBeautiful is better than ugly.Explicit is better than implicit.Simple is better than complex.Complex is better than complicated.Flat is
One person learns Python day 21, python day day21
# For key, value in dic. items (): It is not recommended. The dictionary needs to be converted to a list and then recycled, which is less efficient.# Print (key, value)'''Exercise: Element
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