编辑:想出来,按F12,单击网络,选中"禁用缓存".
我有一个基本的烧瓶服务器,我正在学习d3.问题是chrome给了我一个我正在使用的缓存javascript文件,example.js.
请求方法:GET状态代码:200 OK(来自内存缓存)
服务器本身正在发送一个非缓存的响应,我可以通过直接查看响应来看到:
/static/example.js
我在application.py中添加了这个以防止缓存.
@app.after_request
def add_header(r):
"""
Add headers to both force latest IE rendering engine or Chrome Frame,
and also to cache the rendered page for 10 minutes.
"""
r.headers["Cache-Control"] = "no-cache, no-store, must-revalidate"
r.headers["Pragma"] = "no-cache"
r.headers["Expires"] = "0"
r.headers['Cache-Control'] = 'public, max-age=0'
return r
Run Code Online (Sandbox Code Playgroud)
这是整个代码
import os
import re
from flask import Flask, jsonify, render_template, request, url_for
from flask_jsglue import JSGlue
from flask import send_file
# configure application
app = Flask(__name__)
JSGlue(app)
# …Run Code Online (Sandbox Code Playgroud) 我正在尝试在 python 中探索 Algorithmia 图像标记器。
client.algo("deeplearning/IllustrationTagger/0.2.5")
client.algo("deeplearning/InceptionNet/1.0.3")
Run Code Online (Sandbox Code Playgroud)
但这与这个问题不太相关,因为它通常适用于字典。
for dict in dictList:
print(dict)
Run Code Online (Sandbox Code Playgroud)
这是输出:
//{'安全':0.9950032234191896}
//{'有问题':0.004409242421388626}
//{'显式':0.00011681715113809332}
我可以很好地访问密钥:
for dict in dictList:
for key in dict:
print(key)
Run Code Online (Sandbox Code Playgroud)
//安全的
//可疑的
//显式
但是当我试图解压密钥和值时:
for dict in dictList:
for key, value in dict:
print(key)
print(value)
Run Code Online (Sandbox Code Playgroud)
我收到此错误:
对于键,字典中的值:
ValueError:要解压的值太多(预期为 2)
如何访问键和值?
编辑:我已将 obj 和数组重命名为 dict 和 list 以免与 Javascript 符号混淆。