摘要: 一、多线程 1、多进程是多个资源的集合 2、线程是在进程里面干活 3、线程和线程之间是互相独立的 #实例 def down_load(): time.sleep(5) print('运行完了') def movie(): time.sleep(1) print('movie') start_time 阅读全文
posted @ 2019-11-30 21:38 xmb 阅读(143) 评论(0) 推荐(0) 编辑
摘要: 一、发送请求类 import requests class MyRequest: def __init__(self,url,method='get',data=None,headers=None,is_json=False): method = method.lower() self.url = 阅读全文
posted @ 2019-11-30 18:58 xmb 阅读(169) 评论(0) 推荐(0) 编辑
摘要: 一、操作数据库类 import pymysql class Db: def __init__(self,host,user,password,db,port=3306,charset='utf8'): #构造函数,实例化的时候自动执行构造函数 self.db_info = {'user': user 阅读全文
posted @ 2019-11-30 18:55 xmb 阅读(761) 评论(0) 推荐(0) 编辑
摘要: 一、面向对象 1、面向对象简介: 类(Class): 用来描述具有相同的属性和方法的对象的集合。它定义了该集合中每个对象所共有的属性和方法。对象是类的实例。 类变量:类变量在整个实例化的对象中是公用的。类变量定义在类中且在函数体之外。类变量通常不作为实例变量使用。 数据成员:类变量或者实例变量, 用 阅读全文
posted @ 2019-11-30 18:47 xmb 阅读(112) 评论(0) 推荐(0) 编辑
摘要: 异常处理 1 a = [1,2,3] 2 d = {} 3 #例子1: 4 #判断key异常 5 try: 6 d['name'] 7 except KeyError as e: 8 print("字典key不存在",e) 9 else: 10 print('正常运行') 11 finally: 1 阅读全文
posted @ 2019-11-30 17:50 xmb 阅读(124) 评论(0) 推荐(0) 编辑
摘要: 模拟登录、支付接口 1 import flask,json 2 import tools 3 4 server = flask.Flask(__name__) 5 #登录接口 6 @server.route('/login') 7 def login(): 8 username = flask.re 阅读全文
posted @ 2019-11-30 00:26 xmb 阅读(362) 评论(0) 推荐(0) 编辑
摘要: tools 1 import pymysql,hashlib,redis,time 2 3 #操作数据库 4 def op_mysql(sql,many=True): 5 db_info = {'user': 'xmb', 'password': '123456', 'host': '127.0.0 阅读全文
posted @ 2019-11-30 00:24 xmb 阅读(234) 评论(0) 推荐(0) 编辑
摘要: 一、接口开发 1 #mock接口开发 2 #1、模拟接口 3 #2、给别人提供数据 4 #3、flask是一个web开发框架 5 import flask,json 6 server = flask.Flask(__name__) #把python文件当做一个服务 7 8 @server.route 阅读全文
posted @ 2019-11-21 23:13 xmb 阅读(234) 评论(0) 推荐(0) 编辑
摘要: 一、操作excel_openpyxl模块 1 import openpyxl 2 3 #写excel 4 book = openpyxl.Workbook() 5 sheet = book.active #默认的sheet 6 #sheet1 = book.get_sheet_by_name('sh 阅读全文
posted @ 2019-11-19 22:29 xmb 阅读(163) 评论(0) 推荐(0) 编辑
摘要: 一、jsonpath模块 1 import jsonpath,json,requests,nnlog 2 3 #例子 4 s ={ 5 "error_code": 0, 6 "stu_info": [ 7 { 8 "id": 1, 9 "name": "xmb", 10 "sex": "男", 11 阅读全文
posted @ 2019-11-19 21:50 xmb 阅读(133) 评论(0) 推荐(0) 编辑