2018年3月14日

python之协程--最简单的代码

摘要: # Author: xueyou import time def consumer(name): print("%s 准备吃包子啦!" %name) while True: baozi = yield print("包子[%s]来了,被[%s]吃了!" %(baozi,name)) # c = consumer("ChenRonghua") # ... 阅读全文

posted @ 2018-03-14 22:57 杨学友 阅读(170) 评论(0) 推荐(0) 编辑

python之生成器generator

摘要: 生成器 通过列表生成式,我们可以直接创建一个列表。但是,受到内存限制,列表容量肯定是有限的。而且,创建一个包含100万个元素的列表,不仅占用很大的存储空间,如果我们仅仅需要访问前面几个元素,那后面绝大多数元素占用的空间都白白浪费了。 所以,如果列表元素可以按照某种算法推算出来,那我们是否可以在循环的 阅读全文

posted @ 2018-03-14 22:30 杨学友 阅读(104) 评论(0) 推荐(0) 编辑

2018年3月2日

python之爬新浪爱彩双色球开奖数据

摘要: # Author: xueyou import urllib.request import urllib.parse import re import urllib.request,urllib.parse,http.cookiejar def getHtml(url): cj=http.cookiejar.CookieJar() opener=urllib.request.bu... 阅读全文

posted @ 2018-03-02 00:15 杨学友 阅读(1020) 评论(0) 推荐(0) 编辑

python之爬贴吧图片

摘要: #coding=utf-8 import re import urllib.request def getHtml(url): page = urllib.request.urlopen(url) html = page.read() #print(type(html)) html = html.decode('UTF-8') #print(html) ... 阅读全文

posted @ 2018-03-02 00:14 杨学友 阅读(144) 评论(0) 推荐(0) 编辑

2018年2月5日

python之路集合

摘要: 1 # Author: xueyou 2 3 list_1 = [1,2,3,4,5,6] 4 list_1 = set(list_1) 5 list_2 = {6,7,8,9,0} 6 print(list_1,type(list_1)) 7 #交集 8 print(list_1.intersec 阅读全文

posted @ 2018-02-05 22:34 杨学友 阅读(124) 评论(0) 推荐(0) 编辑

2018年1月30日

python之shopping通过购物单号来完成

摘要: 1 product_list = [ 2 ("Iphone",5800), 3 ("Mac pro",9900), 4 ("watch",3300), 5 ("book",100), 6 ... 阅读全文

posted @ 2018-01-30 23:03 杨学友 阅读(135) 评论(0) 推荐(0) 编辑

2018年1月23日

GitHub 的 Pull Request 是指什么意思?(不是原创,只为借鉴学习)

摘要: 我尝试用类比的方法来解释一下 pull reqeust。想想我们中学考试,老师改卷的场景吧。你做的试卷就像仓库,你的试卷肯定会有很多错误,就相当于程序里的 bug。老师把你的试卷拿过来,相当于先 fork。在你的卷子上做一些修改批注,相当于 git commit。最后把改好的试卷给你,相当于发 pu 阅读全文

posted @ 2018-01-23 17:25 杨学友 阅读(581) 评论(0) 推荐(0) 编辑

2018年1月22日

python之猜年纪

摘要: 一个简单的无限猜年龄的程序。 当猜对或者输入n的时候,结束该程序。 阅读全文

posted @ 2018-01-22 23:41 杨学友 阅读(96) 评论(0) 推荐(0) 编辑

导航