![](https://img-blog.csdnimg.cn/20201014180756918.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Web
Xhfei1224
研究方向:数据挖掘/机器学习/深度学习(博士在读)
展开
-
【Flask】Python flask中在js中如何解析render_template传递给html的数据
转自:https://blog.csdn.net/linshuhe1/article/details/52221514现象说明:在flask中通在使用render_template渲染一个.html页面文件时,可以传入一下参数,在html源码中通过{{变量名}}的方式来调用数据,但是假如在html文件中的JavaScript中想要调用该数据变量,直接调用可能出现识别为Undefined类型的情...原创 2019-09-01 13:02:31 · 3261 阅读 · 0 评论 -
【Flask报错】flask函数已定义参数却出现takes 0 positional arguments but 1 was given的问题
在flask中定义了一个简单的删除数据库内容的路由测试却发现一直报错说delete_history函数定义时没有接受参数,但是检查delete_history函数却发现没有问题。后来想了半天才发现delete_history的路由函数名也是delete_history,那么程序就会调用路由函数而不会调用import进来的delete_history函数,从而导致这个问题将路由函数重命...原创 2019-09-01 16:36:50 · 1494 阅读 · 1 评论 -
【Flask 】render_template 字典传参
context{ 'username':'abc', 'age':18, 'sex':'男' } return render_template('regist.html',**context)两个星号加字典名原创 2019-09-01 20:56:36 · 2646 阅读 · 0 评论 -
【Web】Javascript在静态模板static中使用url_for
简单的说:静态文件中用url_for(“static”)实际上就是被flask 当做了特殊的路由处理。web程序不仅由python代码和模板组成,还包括静态文件 ,例如:代码中引用的图片,javaScripts代码,CSS等 。对静态文件static目录的引用,是被当做特殊的路由处理的 ,因为,默认情况下,flask在程序根目录下名为static的子目录下寻找静态文件/static/<...原创 2019-09-02 08:25:56 · 1102 阅读 · 1 评论 -
【Flask】Flask使用render_template实现中文字符传参
省略....records = {'Id': "1111", 'plate': "京111", 'co': "1112", 'co2': "333", 'isover': "超标"}return render_template('realquery.html',**records,y=1)字典数据records中含有“京”字。当我们将其传送到模板realquery.html中,在realq...原创 2019-09-02 09:18:06 · 1596 阅读 · 0 评论 -
【Json解析】TypeError:theJSONobjectmustbestr,notbytes
file_urllib = json.loads(req)提示TypeError: the JSON object must be str, not ‘bytes’改为file_urllib = json.loads(req.decode('utf-8'))就好了。原创 2019-09-17 16:43:34 · 295 阅读 · 0 评论