python webpy 输出json响应,webpyjson,webpy输出json首
python webpy 输出json响应,webpyjson,webpy输出json首
webpy输出json首先需要引用json包
import json
在Controller类中需要先设置输出Content-Type的响应头为text/json,然后输出json.dumps({})对象即可,如下demo代码:
class JsonTest: def GET(self): web.header('content-type','text/json') return json.dumps({'key1':'value1','key2':'value2'})
就是这么简单。
相关内容
- webpy获得用户post或者get的数据,上传文件示例,webpyp
- python getaddrinfo() 基本使用代码,pythongetaddrinfo,import sy
- Execute a function on multiple argument sets in parallel using a thre
- python urllib.urlopen获得response后检查http响应头中的conten
- python转换字符串为datetime类型,pythondatetime,>>>
- Python 图片蜘蛛人,,[Python]代码#c
- Python设置windows进程的优先级,python优先级,下面的方法
- Python使用PIL裁剪贴图代码,pythonpil贴图代码,Python使用
- python通过HTMLParser抓取网页上的全部链接,pythonhtmlpars
- python压缩和读取.tar.bz2格式的压缩包,python.tar.bz2,#压缩
评论关闭