- 博客(15)
- 收藏
- 关注
原创 crawler(2)
Contents设置代理异常处理Cookies图片爬虫实战re.findall()链接爬虫糗事百科爬虫设置代理from urllib import requestdef use_proxy(proxy_adrr,url): """ this function use a proxy to open a webpage args: proxy_a...
2018-12-30 15:55:27 565
原创 machine learning---kNN(1)
创建测试数据集import numpy as np # import everything from numpyimport operator # operator moduledef createDataSet(): # there are two [] for array group=np.array([[1.0,1.1],[1.0,1.0],[0,0],[0,0.1...
2018-12-13 22:37:44 223
原创 python basics--装饰器
contents装饰器最简单的装饰器目标函数带参数的装饰器目标函数带有不固定参数的装饰器装饰器带参数装饰器装饰器用于动态地为函数扩展功能,同时不改变原本的函数定义最简单的装饰器import timedef decorator(fun): def wrapper(): start=time.time() fun() runtime...
2018-12-13 13:22:48 120
原创 crawler(1)
Contentshttp get 请求http post 请求http get 请求# 利用get请求获取相应网页,并以html形式存储from urllib import requesturl='http://www.baidu.com/s?ie=utf-8&f=8&rsv_bp=1&tn=baidu&wd='keyword='你好'# 利用requ...
2018-12-05 09:05:43 174
原创 multiprocessing(2)---communication between subprocesses
ContentsQueueProgramOutputPipeProgramOutputQueueUsed among multiple processes.Programfrom multiprocessing import Process, Queueimport os, random, time# define the write functiondef proc_writ...
2018-11-22 22:08:47 129
原创 Multiprocessing(1)---Pool
ContentsExample 1 The use of multiprocessing.PoolProgramOutputAnnotationAttentionExample 1 The use of multiprocessing.PoolProgramfrom multiprocessing import Pool # with first alphebet capitalimpor...
2018-11-22 16:31:46 383
原创 python basics(9)--- The Standard Library: A Few Favorites
Contents1. sys(1) sys.argv(2) sys.modules(3) sys.path(4) sys.platform(5) sys.stdin, sys.stdout, sys.stderr2. Heaps3. Deques1. sys(1) sys.argvsys.argv : it is a list containing the command argument...
2018-11-14 14:35:53 151
原创 Python Basics(8)---Modules
Contents1. Modules are programs2. Modules Are Used to Define Things3. Adding Test Code for modules4. Making Your Modules Available5. Attention on sequence slice6. Packages7. Exploring Modules8. Attent...
2018-11-13 14:53:57 145
原创 Python Basics (7) --- Generators
Contents1. Generators2. yield statement1. GeneratorsGenenrators are any functions that have a yield statement.2. yield statementInside a function, when the program meets the return statement,it...
2018-11-12 16:58:42 135
原创 Python Basics---Chapter9 Magic Methods, Properties, and Iterators
Contents1. Preface2. Constructor __ init __3. super function3. Protocol of Python4. The Basic Sequence and Mapping Protocol5. Example: Creat a Infinite Sequence6. The property function1. PrefaceIn ...
2018-11-10 17:38:12 191
原创 Python Basics---Chapter8 Exceptions
Contents1. What is an exception?2. The raise statement3. Custom Exception Class4. Catch and handle the exception5. raise without arguments6. raise another exception7. Catch more than one exception8. C...
2018-11-07 14:19:19 209
原创 Python Bssics--- Chapter7 MakingYour Own Objects
ContentsThe Magic of Objects1. Polymorphism(1) First example==choice()====count()==(2) Second example==repr()==2. Encapsulation3. InheritanceClassThe Magic of ObjectsIn object-oriented programming...
2018-11-04 16:46:57 211
原创 Python Basics---Chapter6 Abstraction (3)
ContentsScoping1. vars()2. The scope of varibles3. globals() and locals()4. Read global varibles inside a function5. Nested ScopeScoping1. vars()vars() : return the scoping dictionary of a varible...
2018-11-03 19:37:32 202
原创 Python Basics ---Chapter6 Abstraction (2)
“I wanted you to see what real courage is, instead of getting the idea that courage is a man with a gun in his hand. It’s when you know you’re licked before you begin, but you begin anyway and see it...
2018-11-02 16:57:49 207
原创 Python Basics---Chapter6 Abstraction (1)
Contents1. An example of programme2. str.split()1. An example of programme#store the full namedef store(data,full_name): # str.split() fnlist=full_name.split() if len(fnlist)==2: ...
2018-10-30 15:19:21 150
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人