1.错误处理 使用try except finally 错误类型(含warning) logging模块记录错误信息 自定义错误类型继承内置错误类型 另 可以在except中捕获错误之后 使用 raise 将错误抛给顶层调用者去处理 2.调试 assert 断言 相当于 if i != 0 为Tru ...
分类:
编程语言 时间:
2017-12-27 22:37:53
阅读次数:
228
多线程下载主要用到http请求中的header Content Length:资源长度 Range:bytes=beg1 end1;beg2 end2,用来控制下载的资源的某一部分 当下载的片段较小时,很容易出错,需要重试,可以使用retry模块通过注解方式实现重试,这个模块非常好用。 Python ...
分类:
编程语言 时间:
2017-12-27 17:48:38
阅读次数:
115
# __init__.py from conf import settings def pack(): response = {} for k,v in settings.PLUGINS.items(): import importlib m_path,classname = v.rsplit('.... ...
分类:
数据库 时间:
2017-12-27 00:17:56
阅读次数:
269
#Python使用raise语句抛出一个指定异常。我们可以使用类(exception的子类)或实例参数调用raise语句引发异常。使用类时程序会自动创建实例。 #例如: 1 >>> raise Exception 2 Traceback (most recent call last): 3 File ...
分类:
其他好文 时间:
2017-12-25 11:44:02
阅读次数:
185
1、Python中的单引号,双引号,三引号 'for', 'from', 'global', 'if', 'import', 'in', 'is', 'lambda', 'not', 'or', 'pass', 'print', 'raise', 're ...
分类:
编程语言 时间:
2017-12-21 18:19:44
阅读次数:
172
实例1:京东商品页面的爬取 import requests url="https://item.jd.com/2967929.html" try: r=requests.get(url) r.raise_for_status() r.encoding=r.apparent_encoding prin ...
分类:
编程语言 时间:
2017-12-19 21:08:50
阅读次数:
808
一、表 二、编写存储过程 三、调用存储过程(本人发现不写commit也可以提交事务,至于为啥我现在也不知道,以后应该会知道吧。) ...
分类:
数据库 时间:
2017-12-17 22:22:23
阅读次数:
161
1 import random 2 3 secret = random.randint(1,10) #随机一个数字作为答案 4 value = secret + random.randint(100,1000) #随便给一个值,防止重复 5 count = 3 #剩余游戏次数 6 while not... ...
分类:
编程语言 时间:
2017-12-17 11:10:32
阅读次数:
169
粗糙实例: 全代码: 即: import requests url="https://item.jd.com/10818358039.html" try: r=requests.get(url) r.raise_for_status()//如果 r.status_code不是200,报错 r.enc ...
分类:
其他好文 时间:
2017-12-10 20:16:42
阅读次数:
131