摘要: 1.Python3中print为一个函数,必须用括号括起来而Python2中print为class print('hello') 2.python3将raw_input和input进行了整合,只有input,输入的为str 3.Python3中/表示真除,%表示取余,//结果取整;Python2中带 阅读全文
posted @ 2018-08-06 14:38 luckylemon 阅读(1351) 评论(0) 推荐(0) 编辑
摘要: 今天写测试工具的时候,去excel取数据,用json解析字符串为字典时报错,后经调试,发现是单引号的原因,将单引号换位双引号即可 阅读全文
posted @ 2018-01-03 16:53 luckylemon 阅读(8497) 评论(0) 推荐(0) 编辑
摘要: 解决方案一:将如下部分加在报错的py文件里 阅读全文
posted @ 2018-01-03 11:02 luckylemon 阅读(1011) 评论(0) 推荐(0) 编辑
摘要: 如果请求数据中包含中文,需要将Encoding选择为utf-8 阅读全文
posted @ 2018-01-02 15:11 luckylemon 阅读(350) 评论(0) 推荐(0) 编辑
摘要: import requests url = 'http://127.0.0.1:5050/index' def apiTestPost(url): datas = { 'a':'cisco3', 'b':'cisco3' } r = requests.post(url,json=datas) print r,type(r),r.t... 阅读全文
posted @ 2017-12-29 14:54 luckylemon 阅读(2950) 评论(2) 推荐(0) 编辑
摘要: #需要被处理的jsonp数据 JSONP = "jsonpreturn({'c': 1, 'd': 2});" #处理方法 def jsonp_to_json(JSONP): JSONP = JSONP.strip(';') #函数名称和要处理的jsonp数据前面部分一致 def jsonpreturn(lists): return lists e... 阅读全文
posted @ 2017-12-29 10:10 luckylemon 阅读(10383) 评论(1) 推荐(0) 编辑
摘要: 前提:基于纯后端服务, post 请求 (Content-Type: application/json,) 1.获取未经处理过的原始数据而不管内容类型,如果数据格式是json的,则取得的是json字符串,排序和请求参数一致 2.将请求参数做了处理,得到的是字典格式的,因此排序会打乱依据字典排序规则 阅读全文
posted @ 2017-12-19 15:37 luckylemon 阅读(28619) 评论(0) 推荐(1) 编辑
摘要: from flask import Flask from flask import jsonify from flask import request from werkzeug.routing import BaseConverter app = Flask(__name__)#重新定义url匹配规则 class RegexConverter(BaseConverter): de... 阅读全文
posted @ 2017-12-19 14:47 luckylemon 阅读(2111) 评论(1) 推荐(0) 编辑
摘要: 解决方案: 发现是因为端口5000被占用了,设置一个其他port就行:app.run(port=5050) 阅读全文
posted @ 2017-08-03 18:26 luckylemon 阅读(610) 评论(0) 推荐(0) 编辑
摘要: Django视图: 当请求为post请求时会遇到CSRF的报错,Django针对CSRF的保护措施是在生成的每个表单中放置一个自动生成的令牌,通过这个令牌判断POST请求是否来自同一个网站,只需要在form表单中添加{% csrf_token %} Django纯后端服务: 当请求是post请求时此 阅读全文
posted @ 2017-08-02 11:20 luckylemon 阅读(434) 评论(0) 推荐(0) 编辑