python初探
行走的夜
这个作者很懒,什么都没留下…
展开
-
python单线程网络爬虫
python编写的简单单线程网络爬虫原创 2015-06-27 18:32:08 · 556 阅读 · 0 评论 -
python向网页提交数据
源代码:以https://www.crowdfunder.com/deals网站为例(该网页并非使用异步加载方法)#-*-coding:utf8-*-import requestsimport re#url = 'https://www.crowdfunder.com/deals'#html = requests.get(url).text#print html.encode("g转载 2015-06-28 10:41:00 · 2936 阅读 · 0 评论 -
python循环判断异常(异常处理)
#循环只有在没有异常的情况下才会退出while True: try: x = input('Enter the first number:') y = input('Enter the second number:') value = x/y print 'x/y is ', value except转载 2015-07-08 16:34:01 · 9303 阅读 · 0 评论 -
python捕捉对象(异常处理)
#捕捉对象:让程序继续运行,但是又因为某种原因记录下错误给用户看try:x = input('Enter the first number:')y = input('Enter the second number:')print x/yexcept (ZeroDivisionError,TypeError,NameError),e:print e运行结果:注转载 2015-07-08 16:17:48 · 783 阅读 · 0 评论 -
Python为什么要self
Python为什么要self 15 March 2011 20:25 Tuesday by 小屋标签: 关键字 Python self接触Python以来,看到类里的函数要带个self参数,一直搞不懂啥麻子原因。晚上特别针对Python的self查了一下,理理。Python要self的理由Python的类的方法和普通的函数有一个很明显的区别,在类的方法必转载 2015-07-09 15:02:40 · 485 阅读 · 0 评论 -
python实现1、使用迭代器实现斐波那契数列;2、从迭代器得到序列
#python使用迭代器实现斐波那契数列>>> class Fibs:def __init__(self):self.a = 0self.b = 1def next(self):self.a,self.b = self.b,self.a+self.breturn self.adef __iter__(self):return self>>> fibs = F转载 2015-07-09 16:32:32 · 1960 阅读 · 0 评论