These days began to learn python, encountered some problems, but also solved some problems.where if __name__ = = ' __main__ ': This sentence estimates a lot of beginners like me are superficial understanding.Here's an explanation:1:__NAME__ is a
Python string: Part 1----String: A collection of ordered characters1, single and double quote strings are the same, single quotes embedded in double quotation marks or double quotation marks embedded in single quotation marks, single quotation marks
In the 01 knapsack problem, choose whether to add an item to the backpack. It is necessary to compare the solution of the sub-problem of the item with the solution of the sub-problem of the item, which leads to a lot of overlapping sub-problems,
Serialization:Variable from memory into a process that can be stored or transferredCalled pickling in Python, also called serialization,marshalling,flattening in other languages, etc.Deserialization (unpickling):Variable contents re-read from
Before using Python to solve the problem, let's say, what is the factor decompositionThe so-called factor decomposition is the first to find the number of all the approximate (approximate: A%b = = 0, that is, a can be divisible by B)For example: 20
Python can output text using print, and several text outputs are described below
Pure string
Use single or double quotation marks: single and double quotes with no difference, but pair: print "Hi friend!"
Formatting Operators• Strings can use formatting symbols to represent special meanings%c convert into characters%s Priority str () function for string conversion%d/%i turn into a signed decimal number%o Turn unsigned octal number%e/%e turn into
Usage:-------del for list operation, delete one or more successive elements.# define a list>>> a = [1,2,3,4] >>> a[1,2,3,4] >>> del a[0] # delete No. 0 element >>> a[2,3,4]>>> del a[ 1:3] # Removes the element starting from the 1th element to the
Python The birth is very early, but the real hot time is not long. At present , the Python language is widely used in the field of system programming, graphics processing, mathematical processing, Text processing, database programming, network
Python Gets the memory information of Linux1. Install Psutil Source codeHttps://pypi.python.org/pypi?:action=display&name=psutil#downloadsFind psutil-5.2.2.tar.gz Click to download Shell # tar XZVF psutil-5.2.2.tar.gzShell # CD psutil-5.2.2Shell #
Extracting the contents of a Web page with regular expressions is rather cumbersome, and here is a Python library that extracts data from an HTML or XML file: Beautiful Soup. It allows you to navigate your favorite documents, find them, and modify
Linux Environment:
You can use the mirror source directly, plus-I specify the address:
1 sudo pip install-i module name
If a non-trusted error occurs:
You need to add the command after the
1 sudo pip install-i --trusted-host
List parsing, primarily for dynamically creating lists
This article focuses on the use of the combination of lambda, map (), and filter () with the list parsing statements
The basic syntax for list parsing is: [Expr for Iter_var in iterable]
At the
Machine learning Combat This book is written in python2.x environment, and python3.x many functions and 2.x in the name or use the same way, so the original book content needs to be corrected, the following is a simple record of the process of the
Python day1, day1
Python is an interpreted language.
Python 2 or 3 options:
Python 2.7 is the latest version of 2 and the last version. The update support will be stopped by 2020, but companies that are currently using or have completed development
Python crawler practice: 2017 ranking of the best universities in China, python7 7
Capture content:
Capture the top 10 university rankings, university names, and total scores from the best universities in China, and align the data in the
Python coding minutes, python minutes
1. map, filter, reduce1) map (func, input_list)Apply the function to each element in the input list, for example:Input_list = [1, 2, 3, 4, 5]
Def pow_elem (x ):"""Perform multiplication operations on x: Param x::
Install Beautifulsoup and beautifulsoup1. Obtain the Tag1.find _ all method (1) find_all (name = 'tag _ name', attrs, recursive, text, ** kwargs)
Name: The name corresponding to the tag. When multiple tags are included, a list is returned. You can
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