上一页 1 2 3 4 5 6 7 ··· 11 下一页
摘要: 我们常常听说测试http接口、测试java接口,测试socket接口等等;那么python这么强大的语言当然也可以用来开发接口了。 flask模块介绍: python中用来开发接口的模块:flask,flask是一个第三方的模块需要pip install flask 就可以安装使用 准备: 在too 阅读全文
posted @ 2017-11-30 18:23 D.零下的小书屋 阅读(588) 评论(0) 推荐(0) 编辑
摘要: urllib模块去请求的确比较麻烦,需要不断的encode和decode;而requests模块就比较方便了,它是基于requests模块开发的第三方模块,安装简单只需要 pip install requests即可。 import requests url= 'http://127.0.0.1:8 阅读全文
posted @ 2017-11-24 14:28 D.零下的小书屋 阅读(263) 评论(0) 推荐(0) 编辑
摘要: 一、操作网络发送请求 from urllib.request import urlopen #发送请求 from urllib.parse import urlencode #用来把字典形式转换成k=v形式;username = dusir&pwd = 123456 ####get请求 url='h 阅读全文
posted @ 2017-11-24 11:50 D.零下的小书屋 阅读(172) 评论(0) 推荐(0) 编辑
摘要: import base64 #base64也是用来加密的,但是这个是可以解密的 s = "username" byte类型print(base64.b64encode(s.encode()) ) #加密 new_s = base64.b64encode(s.encode()) old_s = base64.b64decode(new_s).decode()) def bs64_dat... 阅读全文
posted @ 2017-11-24 11:08 D.零下的小书屋 阅读(382) 评论(0) 推荐(0) 编辑
摘要: 一、异常处理 在程序运行的过程中,总会遇到各种各样的错误。程序一出错就停止运行了,下面的代码就不能运行了;这时候就需要捕捉异常,通过捕捉异常,再去做对应的处理。 像这种情况我们就需要捕捉异常;捕捉异常使用try....except....关键字,就是你在写代码的时候,先要考虑到这段代码可能会出现什么 阅读全文
posted @ 2017-11-23 22:32 D.零下的小书屋 阅读(326) 评论(0) 推荐(0) 编辑
摘要: ###内置函数 print(all([1,2,3,4]))判断可迭代的对象里面的值是否都为真 print(any([0,1,2,3,4]))判断可迭代的对象里面的值是否有一个为真 print(id(list1)) #查看内存地址 print(bin(10))十进制转二进制 以下是强制类型转换 print(bool('s'))把一个对象转换成布尔类型 int() float... 阅读全文
posted @ 2017-11-20 17:08 D.零下的小书屋 阅读(187) 评论(0) 推荐(0) 编辑
摘要: ''' 有一个存着学生成绩的文件,里面存的是json串,json串读起来特别不直观,需要你写代码把它都写到excel中,并计算出总分和平均分,json格式如下 { "1":["小花",99,100,98.5], "2":["小王",90,30.5,95], "3":["小明",67.5,49.6,88] } 分析: 1、json需要读出来编程字典json.load 2、写进ex... 阅读全文
posted @ 2017-11-20 15:43 D.零下的小书屋 阅读(6164) 评论(0) 推荐(0) 编辑
摘要: python操作excel,python操作excel使用xlrd、xlwt和xlutils模块,xlrd模块是读取excel的,xlwt模块是写excel的,xlutils是用来修改excel的。这几个模块使用pip安装即可,下面是这几个模块的使用。 阅读全文
posted @ 2017-11-12 16:50 D.零下的小书屋 阅读(363) 评论(0) 推荐(0) 编辑
摘要: import hashlib def md5_passwd(str,salt ='aaaaa') str = str + salt m = hashlib.md5()#构造一个MD5对象 m.update(str.encode()) #转为byte res = m.hexdigest() #转为16进制输出 return res 阅读全文
posted @ 2017-11-12 16:28 D.零下的小书屋 阅读(151) 评论(0) 推荐(0) 编辑
摘要: 用于处理一些请求的信息头如:content-type;配置原件-http请求信息头 阅读全文
posted @ 2017-10-30 10:32 D.零下的小书屋 阅读(166) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 ··· 11 下一页