【发布时间】:2014-09-06 10:03:03
【问题描述】:
我最近将 django 服务器从 python 版本 2.7 转换为 python 版本 3.4.1。 我的 request.body 是一个序列化为 JSON 的数组。反序列化后,它将是一个 python 列表。
不幸的是,json.loads 似乎不再需要原始字节(这就是 request.body 的内容)。
我该如何解决这个问题?
def index(request):
if request.method == 'POST':
print("Made it here!")
registered = []
notRegistered = []
print("Is it this?")
print(repr(request.body))
data = json.loads(request.body)
print("Did I make it here?")
最后一次调用 print 永远不会执行,这就是为什么我假设它与 json.loads() 相关
【问题讨论】:
标签: python json django python-2.7 python-3.x