我創建了一個表單,當我點擊提交按鈕時,我將3值賦給一個javascript dict併發送給python腳本來處理,但是我的web瀏覽器告訴我一個錯誤!在python輸出中刪除`u`字符
從Json的錯誤:{u'food ':90,u'cargo':70,u'fuel':50}的SyntaxError
controller.js
function customiseCtrl($xhr){
var self = this;
checkPoint();
this.process = function(){
if (checkPoint()){
var newPlayer = {"fuel":value, "food":value2, "cargo":value3 };
$xhr('POST', '/process', newPlayer, function (code, response) {
self.x = response;
});
}
};
}
/過程 - > Python腳本(我想讀的「信息」的信息,並將其寫入到谷歌應用程序引擎。
def post(self):
user = users.get_current_user()
player = Player();
info = json.loads(self.request.body)
player.fuel = info.fuel
self.response.out.write(info)
Python的'repr'(這裏隱式調用)不是爲了產生JSON而設計的。 – robert 2012-03-20 16:45:48
[Removing u in list](http://stackoverflow.com/questions/9773121/removing-u-in-list) – geoffspear 2012-03-20 17:24:32