We call the same thing a class, where the same attributes of the same thing can be abstracted, and some of the same action behavior can be abstracted into methods.For example, a car is a class that includes attributes such as Price, brand, and so on.
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
The use map() of functions, the user entered the non-standard English name, the first letter capitalized, other lowercase canonical name. Input: [‘adam‘, ‘LISA‘, ‘barT‘] , output: [‘Adam‘, ‘Lisa‘, ‘Bart‘] :1 defNormalize (name):2Name=Name.lower
The basic data types in Python are: int (numeric) str (string) bool (Boolean) List (list) Tupel (tuple) dict (dictionary)Class-to-object relationshipsHow do I view the class of an object? To get a type by type" Hey " Print (Type (temp))Output: How
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
Python Practice (i):Give a positive integer of no more than 5 digits, and judge how many of them, in turn, print out the digits of single, 10, Hundred, thousand, and million digits:Num = int (Input (' please enter a number: ')) lst = []for IINSTR
Because the work needs to collect some data frequently, I want to use the crawler to achieve the automation of the more repetitive tasks.At present, my python situation, followed by a few tutorials, but also understand the point of the foundation,
1 " Daniel Wu " 2 for inch Name: 3 " Utf-8 " )4for in i_by:5 i_b = Bin (i_bin) 6 print(i_b)Output Result:0b101101000b101001100b10010110Let's take a detailed reading of each conversion step:For I in name: Get all the
This article mainly introduces Python based on the time module to find the program runtime of the method, involving the use of the Python timing module and numerical operations related operation skills, the need for friends can refer to the next
New employees are automatically added to the contact list of their respective departments ., Contact List
Requirement: every time a new employee is hired, the company needs to manually add these people to the contact group of the corresponding
Python socket programming, pythonsocket
1. What is socket?
Python about Socket functions please see http://docs.python.org/library/socket.html
A socket is also called a "socket". It is used to describe the IP address and port. It is a communication
Python accesses http GET/POST, and python accesses getpost
With urllib and urllib2, you can easily access http.
The following example shows how to GET and POST http: // 127.0.0.1/cgi/test.
The query string in the ordinary sense is used.
POST accept
Python -- virtualenv,
When multiple projects are deployed on the same server, different versions of django or other python libraries may be used for the project. In this case, virtualenv can be used to create an independent python runtime
Exercise Question 2 from projecteuler.net website,
0. The questions are as follows:
Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be:
1, 2, 3, 5, 8, 13, 21, 34
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