1 #author F2 3 #built-in functions4 Print(ABS (-5))#Absolute Value5 Print(All ([0,-5, 13]))#true if an iterator object is true if there is not true returns false6 Print(Any ([0,-5, 13]))#If there is an object true returns True if neither is true
Basic information for a collection1 #-*-coding:utf-8-*-2 #LC3 4list_1 = [1,2,5,2,4,1,9,5]5Set_1 = Set (list_1)#The set is unordered, the weight-dissipating6 Print(Set_1,type (set_1))7 8Set_2 = Set ([1,3,4,34,9])9 Print(set_1,set_2)Ten One
The items in the list should be included in square brackets,You can add, delete, or search for items in a list.Because you can add or delete items, the list is a mutable data type,That is, this type can be changed.Tuples and lists are very similar,
1. Interpreter and content encoding two lines of code on the head of a python file: #!/usr/bon/env pythonspecify what interpreter to use to run the script and where the interpreter is located #-*-coding:utf-8-*-Specifies that the file is encoded as
First, recursive call1. A function call itself is recursive call, at most one function recursively call themselves 999 times, more than will be wrong2. Recursion must have a definite end condition3. Each time a deeper level of recursion is reached,
Decorative DeviceAn adorner is essentially a Python function that allows other functions to add extra functionality without any code changes, and the return value of the adorner is also a function object.Let's look at a simple example:def run ():
This chapter outlines:The difference between a class's object and a class the namespace of the class __dict__ The namespace of the object of the class __dict__ the binding method and the unbound method class and the type variable variant
FTP Server1) Read file name2) Check if the file exists3) Open File4) Check the file size5) Send file size to client6) such as client confirmation7) Start reading and sending data on the side Download
One: Dynamic import importlibIn the process of running the program, depending on the variable or configuration dynamically decide which module to import, you can use the module importlibImportlib Use ExampleTwo: Assert assertIf the next program
Excerpt from the networkPython itself does not have a switch statement, with the following 3 workarounds: A. Using dictionaryValues = {VALUE1:DO_SOME_STUFF1,VALUE2:DO_SOME_STUFF2,...VALUEN:DO_SOME_STUFFN,}Values.get (Var, do_default_stuff) ()
1. List, tuple operations recommended books chasing kites White deer original Linda See the United States2. String manipulation3. Dictionary operation4. Collection Operations5. File operation6. Character encoding and transcoding7. Built-in
Monitoring Nginx Log, if someone attacks, then blacklist, the following steps:1. Read the log file2. Separating files, removing IP3. Place the removed IP into the list and then interpret the number of IP4. If the set number of times is exceeded, the
#-*-coding:cp936-*-# 1 Open File# Open (fileName, mode)# Number of references: FileName File name# Mode Open mode# W opens in write mode.# A opens in Append mode (starts with EOF and creates a new file if necessary)# r+ Open in read/write mode# w+
This article is to introduce the use of Python developed crawler framework Talonspider simple introduction and use of methods, the need for small partners can refer to the following
1. Why do you write this?
Some simple pages, do not need to use a
Topic One:
Make a set of data in 3 seconds, even before the odd number (note the method of not using a for-while loop)The format is as follows1,2,3,4,5,6,7,8,9,10The output is2,1,4,3,6,5,8,7,10,9
Solution: Since we cannot use for and while to
This article mainly introduces Python using QRCode module to generate two-dimensional code examples of the relevant information, the need for friends can refer to the following
Python generates two-dimensional code using the QRCode module
QRCode
Here is a small series of python for you to bring an OS operation method (detailed). Small series feel very good, now share to everyone, also for everyone to make a reference. Let's take a look at it with a little knitting.
1. Os.path.driname (PATH)
I. Python Basics
Mathematical Operators
Operator
Operation
Example
Evaluate
**
Index
2 ** 3
8
%
Returns the remainder.
22% 8
6
//
The number of businesses is rounded up.
22 // 8
Class View,
Class View
Usage principles
The less code the better
Never repeat the code
View should only contain the presentation logic, not the business logic
Keep view logic clear and simple
Do not use CBVs as the 403,404,500 error handler
Python Series 4 and python SeriesDirectory
Recursive Algorithm Analysis
Analysis of Bubble Sorting
Parser
1. recursion 1. Definition of Recursion
Recursion (Recursion) is also a progressive process. In mathematics and computer science, it refers
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