我试图通过输出Json在Django中创建REST Api.如果我在终端使用curl发出POST请求,我会遇到问题.我得到的错误是
您通过POST调用此URL,但URL不以斜杠结尾,并且您设置了APPEND_SLASH.在保持POST数据时,Django无法重定向到斜杠URL.将表单更改为指向127.0.0.1:8000/add/(注意斜杠),或在Django设置中设置APPEND_SLASH = False.
我的url.py是
from django.conf.urls.defaults import patterns, include, url
import search
# Uncomment the next two lines to enable the admin:
# from django.contrib import admin
# admin.autodiscover()
urlpatterns = patterns('',
url(r'^query/$', 'search.views.query'),
url(r'^add/$','search.views.add'),
)
Run Code Online (Sandbox Code Playgroud)
我的意见是
# Create your views here.
from django.http import HttpResponse
from django.template import Context,loader
import memcache
import json
def query(request):
data=['a','b']
mc=memcache.Client(['127.0.0.1:11221'],debug=0)
mc.set("d",data);
val=mc.get("d")
return HttpResponse("MEMCACHE: %s<br/>ORIGINAL: %s" % (json.dumps(val),json.dumps(data)) )
def add(request):
#s=""
#for data in request.POST:
# s="%s,%s" % (s,data) …Run Code Online (Sandbox Code Playgroud) 我想知道创建源译者的策略是什么,即从一种高级语言到另一种高级语言的翻译.我想到的两种方式是
1-将一种语言的语法树更改为其他语言语法树2-将其更改为中间语言,然后将其转换为其他高级语言
我的问题是,是否有可能使用这两种策略进行转换,哪种更可行,任何人都可以参考某些转换器完成的任何理论或实现,如上述任何方法.有没有任何标准的基于xml的中间语言,我知道xmlvm使用xml作为中间语言,但它没有提供任何适当的中间语言规范.
我有一个使用Mongo API的CosmosDB安装程序。我在文档的某个字段上有一个带有散列碎片的集合。当我运行类似db.collection.remove或的命令时db.collection.deleteMany,出现以下错误。
Command deleteMany failed: query in command must target a single shard key.: {"message":"Command deleteMany failed: query in command must target a single shard key."}
考虑到我希望查询在所有分片上运行,我不确定如何在查询中提及分片键。
考虑一下简短的语法
S -> Bc | DB
B -> ab | cS
D -> d | epsilon
Run Code Online (Sandbox Code Playgroud)
第一组是
FIRST(S) ={a,c,d}
FIRST(B) = { a,c }
FIRST(D)= { d, epsilon }
Run Code Online (Sandbox Code Playgroud)
在它里面
Follow(S)={ Follow(B) }
Run Code Online (Sandbox Code Playgroud)
和
Follow(B) ={ c , Follow(S) }
Run Code Online (Sandbox Code Playgroud)
我的问题是如何解决这个循环依赖?