通过ajax调用.py脚本,编码问题

时间:2019-02-25 09:40:04

标签: python jquery ajax encoding

我正在尝试通过jquery ajax方法从.py脚本获得正确的响应:

$.ajax({
                              url:'./pyscripts/word_zakup_odluka.py',
                              type:'POST',
                              datatype:'json',
                              data:JSON.stringify(json_odluka),
                              success:function(response){
                                pythonresponse=response['message']
                              }
                            })

.py脚本

print("Content-Type: application/json\n\n")
json_odluka=json.load(sys.stdin)
sys.stdout.write(json.dumps({'success:'true','message':json_odluka},indent=1))
sys.stdout.close()

我通过ajax发送的对象是:

{opcinegrada: "općine ", opcinagrad: "općina ", opcinigradu: "općini ", opcinskogradsko: "općinsko", klasasuglasnost: "", …}

我想用ć字符获得相同的对象,但我却得到:

{opcinegrada: "općine ", opcinagrad: "općina ", opcinigradu: "općini ", opcinskogradsko: "općinsko", klasasuglasnost: "", …}

在这种情况下,我在哪里以及如何设置正确的编码?先感谢您 !

0 个答案:

没有答案