tornado RequestHandler request.body & request.arguments

request.body , 请求的原始内容,post方式放在body中的。

request.arguments, body参数和url参数的统一体, 同时也是经过“加工”,解码的。

eg.在对接其他平台时,对方可能post过来的body内容是这样的:

———————————————2b556c28ca53
Content-Disposition: form-data; name="order_number"

LT40OQ95A5N67
———————————————2b556c28ca53
Content-Disposition: form-data; name="shipping_status"

5
———————————————2b556c28ca53
Content-Disposition: form-data; name="shipping_status_desc"

充值失败
———————————————2b556c28ca53
Content-Disposition: form-data; name="shipping_status_message"


———————————————2b556c28ca53———————————————

这就是所谓的“原始内容”, 可以自己split。

然而更简单的方式是直接用request.arguments读取(以上内容可以很愉快的得到一个json字符串)。

转载请注明来源:http://www.cnblogs.com/Tommy-Yu/p/5715853.html

参考:http://stackoverflow.com/questions/34818996/tornado-what-is-the-difference-between-requesthandlers-get-argument-get-qu

原文地址:https://www.cnblogs.com/Tommy-Yu/p/5715853.html