0
我正在使用Python来使用urllib查询WordPress.org API。 WordPress.org反过来决定用一个编码的PHP StdClass对象进行响应。如果我使用PHP,那将会很棒,但我必须使用Python。任何想法如何把它变成一本字典(不含前缀)?在Python中解码StdClass
apiUrl = "http://api.wordpress.org/themes/info/1.0/"
body = urllib.urlencode({
'action': "query_themes",
'request': {
"browse": "featured",
'fields': {
'download_link': True,
'preview_url': False,
'screenshot_url': False,
'description': False,
'sections': False,
'screenshots': False,
'downloaded': False,
'screenshot_count': False
}
}
}, True)
request = urllib.urlopen(apiUrl, body)
response = request.read(200)
这是回访(截断):
O:8:"stdClass":2:{
s:4:"info";
a:3:{
s:4:"page";
i:1;
s:5:"pages";
i:41;
s:7:"results";
i:610;
}
s:6:"themes";
a:15{
i:0;
O:8:"stdClass":10:{
#BLAH BLAH
}
}
}