To learn the Python crawler, we have to learn a total of the following points:
Python Basics
Usage of urllib and URLLIB2 libraries in Python
Python Regular Expressions
Python crawler Frame Scrapy
More advanced features of Python crawlers
>>> true or False and Falsetrue first two so you don't have to judge #########################>>> (true or false) after you get true and falsefalse########## #流程控制if ... else single branch if condition:: Is the syntax format that satisfies the
1 #-*-coding:utf-8-*-2 ImportUrllib23 fromBs4ImportBeautifulSoup4 5 classDbxs:6 7 def __init__(self):8Self.pageindex =09Self.enable =TrueTenSelf.file =None OneSelf.content = [] A - - #get the contents of an HTML page the
Yang Hui Triangle, is a geometric arrangement of two-term coefficients in triangles
Each number equals two of the sum above it.
Each line of numbers is symmetrical, starting from 1 to become larger.
The number of the nth row has n
C:\users\administrator>python3python 3.6.1 (V3.6.1:69C0DB5, Mar, 18:41:36) [MSC v.1900-bit (AMD64)] on Win32 Type ' help ', ' copyright ', ' credits ' or ' license ' for more information.>>> exit () c:\users\administrator> Python2python 2.7.13 (V2.7.
The use of functions requires a clear definition of the stage and the call stageClosure function: A function defined inside a function that contains the use of an external domain name word, rather than a reference to the global role domain name
1. Character Encoding first knowledgeThe original character set is the ASCII,ASCII (American Standard Code for information interchange, US Standards Information Interchange Code), a set of computer coding systems based on the Latin alphabet, mainly
#-*-coding:utf-8-*-#1, DictionariesDict = {' name ': ' Zara ', ' age ': 7, ' class ': ' First '}#字典转为字符串, return: {' age ': 7, ' name ': ' Zara ', ' class ': ' First '}Print type (str (dict)), str (DICT)#字典可以转为元组, return: (' age ', ' name ', '
Test data show:#coding: Utf-8__author__ = ' Similarface '‘‘‘Implement K-Mean algorithmAlgorithm Summary:-----------------------------Input: All data points A, number of clusters KOutput: center point for k clustersRandom selection of K Initial
Python file related operations open fileOpen the file, using the Open method, will return the file's handle, as follows:f = open (' Test_file.txt ', ' R ', encoding= ' utf-8 ')In the above code, the Open () method opens a file and other related
Gross steps1 receives the text in the request, processing the text through the stutter participle.Seg_generator = jieba.cut (text)#use stuttering participle, or you can not useStopwords = pd.read_csv (path +"/stop_words_zh_utf-8.txt",
Tag: Pos split () Assert self func Purpose calculation command--Numbers: integers, long integers, floating-point numbers, complex numbersString:1. Single quotation mark (The Space tab remains the same)2. Double quotation marks ()3. Three quotation
1. The object that directly acts on for the loop is called an iterative object:Iterable。 可以被next()函数调用并不断返回下一个值的对象称为迭代器:Iterator。2, generators are Iterator objects, but,, list dict str Although Yes Iterable , but not Iterator .Turn list , dict
Python function definitionA function is to encapsulate a set of statements by a name (function name), and to execute the function, simply call the name of its functions.Characteristics
Reduce code Duplication
Make programs extensible
One, Python single-line comment sign (#)The pound sign (#) is often used as a single-line comment symbol, and any data on its right will be ignored as a comment when using # in code.Print 1 #输出1#号右边的内容在执行的时候是不会被输出的.Second, batch, multi-line comment
For a string, design an algorithm that only makes an inverse adjustment between the words in the string, that is, the string is made up of some space-delimited parts, and you need to reverse those parts.Given an original string A and his length,
36. IO model, 36io Model
In particular, this essay is copied to egon (Lin Haifeng ).
I. IO model Introduction
To better understand the IO model, we need to review in advance: synchronous, asynchronous, blocking, non-blocking
What are the
Use of built-in string methods and built-in string MethodsUse of built-in string Methods
Set string: st = 'Hello kitty'1. count the number of elements
Print (st. count ('l') # The result is 2.2. uppercase letters
Print (st. capitalize () # The
Basic Python-string, basic python stringBasic string syntax
Print () Output
In Python 3, strings are Unicode encoded. That is to say, Python strings support multiple languages.
Chr () encoding into characters ord()Integer representation of
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