AJAX Post Request to Python Flask
This question already has an answer here:
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