摘要: 1 # -*- coding:utf-8 -*- 2 import requests 3 import json 4 import re 5 import os 6 import gevent 7 import time 8 import random 9 from multiprocessing.dummy import Pool as ThreadPool 10 from ... 阅读全文
posted @ 2017-04-19 13:40 Erick-LONG 阅读(2488) 评论(1) 推荐(0) 编辑
摘要: 1 #!/usr/bin/env python 2 # -*- coding:utf-8 -*- 3 import matplotlib.pyplot as plt 4 from wordcloud import WordCloud,STOPWORDS,ImageColorGenerator 5 import jieba 6 from scipy.misc import imrea... 阅读全文
posted @ 2017-04-18 21:59 Erick-LONG 阅读(452) 评论(0) 推荐(0) 编辑
摘要: 1 import string 2 path = 'waldnn' 3 with open(path,'r') as text: 4 words = [raw_word.strip(string.punctuation).lower() for raw_word in text.read().split()] 5 words_index = set(words) 6 co... 阅读全文
posted @ 2017-03-10 19:23 Erick-LONG 阅读(1593) 评论(0) 推荐(0) 编辑
摘要: 生产者消费者模型 消费者consumer()函数是一个生成器函数,每次执行到yield时即挂起,并返回上一次的结果给生产者。生产者producer()接收到生成器的返回,并生成一个新的值,通过send()方法发送给消费者。 阅读全文
posted @ 2017-03-05 12:25 Erick-LONG 阅读(134) 评论(0) 推荐(0) 编辑
摘要: 一、low版 二、版本二 阅读全文
posted @ 2017-03-04 20:25 Erick-LONG 阅读(228) 评论(0) 推荐(0) 编辑
摘要: 进程池 p = Pool(5) p.apply 每个任务是排队进行。进程.join() # 等待 p.apply_async 每一个任务都并发执行可设置回调函数,进程.无join();进程daemon=True # 不等待 阅读全文
posted @ 2017-03-04 12:57 Erick-LONG 阅读(148) 评论(0) 推荐(0) 编辑
摘要: 进程池 阅读全文
posted @ 2017-03-03 08:09 Erick-LONG 阅读(239) 评论(0) 推荐(0) 编辑
摘要: 1 import queue 2 import threading 3 4 q = queue.Queue(10) 5 def product(i): 6 print('put:'+ str(i)) 7 q.put(i) 8 9 def customer(i): 10 msg = q.get() 11 print(msg) 12 13 fo... 阅读全文
posted @ 2017-03-02 21:59 Erick-LONG 阅读(177) 评论(0) 推荐(0) 编辑
摘要: import threadingimport timenum = 0lock = threading.RLock()def fun(): lock.acquire() global num num+=1 time.sleep(1) print(num) lock.release()for i in 阅读全文
posted @ 2017-03-02 21:15 Erick-LONG 阅读(148) 评论(0) 推荐(0) 编辑
摘要: 1 #!/usr/bin/env python 2 # -*- coding:utf-8 -*- 3 import socket 4 sk1 = socket.socket() 5 sk1.bind(('127.0.0.1',8001,)) 6 sk1.listen() 7 8 inputs = [sk1,] 9 outputs = [] 10 message_dict = ... 阅读全文
posted @ 2017-02-28 21:53 Erick-LONG 阅读(209) 评论(0) 推荐(0) 编辑