forked from lzjun567/python_scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtestt.py
41 lines (29 loc) · 793 Bytes
/
testt.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# encoding: utf-8
__author__ = 'liuzhijun'
import urllib.request as urllib
from collections import deque
def cache(func):
saved = {}
def wrapper(url):
if url in saved:
return saved[url]
else:
page = func(url)
saved[url] = page
return page
return wrapper
def web_lookup(url, saved={}):
if url in saved:
return saved[url]
page = urllib.urlopen(url).read()
saved[url] = page
return page
@cache
def web_lookup(url):
return urllib.urlopen(url).read()
def main():
import jieba
seg_list = jieba.cut("最实用的微信小程序大全,持续更新中...", cut_all=False)
print("Default Mode: " + "/ ".join(seg_list)) # 精确模式
if __name__ == '__main__':
main()