AJAX Post Request to Python Flask

This question already has an answer here:

  • How do I write JSON data to a file? 10 answers

  • From the flask documentation,

    If the mimetype is application/json this will contain the parsed JSON data. Otherwise this will be None .

    The key there is that .json is the parsed JSON data, not the original string. If you want to write it to a file, you'll need to convert it back to a string it first, perhaps by using json.dumps() :

    with open("C:test.txt", 'w') as f:
        f.write(json.dumps(regions))
    
    链接地址: http://www.djcxy.com/p/48688.html

    上一篇: Python:将API结果保存到json文件中?

    下一篇: AJAX发布请求到Python Flask