English 中文(简体)
• 如何从网上的异构体中解脱POST数据?
原标题:How to decode POST data from github in web.py?

(这个问题与

这是我从一个阴 the中获取的持久性有机污染物数据:

payload=%7B%22pusher%22%3A%7B%22name%22%3A%22none%22%7D%2C%22repository%22%3A%7B%22name%22%3A%22test%22%2C%22size%22%3A84%2C%22has_wiki%22%3Atrue%2C%22created_at%22%3A%222012%2F01%2F12%2001%3A04%3A25%20-0800%22%2C%22watchers%22%3A1%2C%22private%22%3Afalse%2C%22fork%22%3Afalse%2C%22url%22%3A%22https%3A%2F%2Fgithub.com%2Fgonvaled%2Ftest%22%2C%22pushed_at%22%3A%222012%2F01%2F12%2001%3A05%3A26%20-0800%22%2C%22has_downloads%22%3Atrue%2C%22open_issues%22%3A0%2C%22has_issues%22%3Atrue%2C%22homepage%22%3A%22%22%2C%22description%22%3A%22%22%2C%22forks%22%3A1%2C%22owner%22%3A%7B%22name%22%3A%22gonvaled%22%2C%22email%22%3A%22gonvaled%40gonvaled.com%22%7D%7D%2C%22forced%22%3Afalse%2C%22after%22%3A%2214209371dcbdd95cc3ef5c4a07d80edd42f1295c%22%2C%22deleted%22%3Afalse%2C%22ref%22%3A%22refs%2Fheads%2Fmaster%22%2C%22commits%22%3A%5B%5D%2C%22before%22%3A%2214209371dcbdd95cc3ef5c4a07d80edd42f1295c%22%2C%22compare%22%3A%22https%3A%2F%2Fgithub.com%2Fgonvaled%2Ftest%2Fcompare%2F1420937...1420937%22%2C%22created%22%3Afalse%7D

我可以这样说:

urllib.unquote(data)

为此:

payload={"pusher":{"name":"none"},"repository":{"name":"test","size":84,"has_wiki":true,"created_at":"2012/01/12 01:04:25 -0800","watchers":1,"private":false,"fork":false,"url":"https://github.com/gonvaled/test","pushed_at":"2012/01/12 01:05:26 -0800","has_downloads":true,"open_issues":0,"has_issues":true,"homepage":"","description":"","forks":1,"owner":{"name":"gonvaled","email":"[email protected]"}},"forced":false,"after":"14209371dcbdd95cc3ef5c4a07d80edd42f1295c","deleted":false,"ref":"refs/heads/master","commits":[],"before":"14209371dcbdd95cc3ef5c4a07d80edd42f1295c","compare":"https://github.com/gonvaled/test/compare/1420937...1420937","created":false}

在<代码>有效载荷= bit之后,我可以在那里看到。 我提出的问题是:全面数据的形式是什么? 我怎么能够利用标准的餐厅只获得有效载荷比照;我更愿意避免把自我扼杀分开,因为我不知道这些特例。

github help page,建议为Sinatra服务器实施:

post  /  do
  push = JSON.parse(params[:payload])
  "I got some JSON: #{push.inspect}"
end

如何使用<条码> 在座标上,有标准图书馆? 鲁比法的最初步执行情况是什么? 我的最终目标是让所有持久性有机污染物数据作为字典获得。

最佳回答

为此:

import json
import urlparse
data = urlparse.parse_qs(r)
print json.loads(r[ payload ][0])

www.un.org/Depts/DGACM/index_french.htm

问题回答
import urlparse
import json
s = "payload=%7B%22pusher%22%3A%7B%22name%22%3A%22none%22%7D%2C%22repository%22%3A%7B%22name%22%3A%22test%22%2C%22size%22%3A84%2C%22has_wiki%22%3Atrue%2C%22created_at%22%3A%222012%2F01%2F12%2001%3A04%3A25%20-0800%22%2C%22watchers%22%3A1%2C%22private%22%3Afalse%2C%22fork%22%3Afalse%2C%22url%22%3A%22https%3A%2F%2Fgithub.com%2Fgonvaled%2Ftest%22%2C%22pushed_at%22%3A%222012%2F01%2F12%2001%3A05%3A26%20-0800%22%2C%22has_downloads%22%3Atrue%2C%22open_issues%22%3A0%2C%22has_issues%22%3Atrue%2C%22homepage%22%3A%22%22%2C%22description%22%3A%22%22%2C%22forks%22%3A1%2C%22owner%22%3A%7B%22name%22%3A%22gonvaled%22%2C%22email%22%3A%22gonvaled%40gonvaled.com%22%7D%7D%2C%22forced%22%3Afalse%2C%22after%22%3A%2214209371dcbdd95cc3ef5c4a07d80edd42f1295c%22%2C%22deleted%22%3Afalse%2C%22ref%22%3A%22refs%2Fheads%2Fmaster%22%2C%22commits%22%3A%5B%5D%2C%22before%22%3A%2214209371dcbdd95cc3ef5c4a07d80edd42f1295c%22%2C%22compare%22%3A%22https%3A%2F%2Fgithub.com%2Fgonvaled%2Ftest%2Fcompare%2F1420937...1420937%22%2C%22created%22%3Afalse%7D"
L = urlparse.parse_qsl(s)
for k, v in L:
    print k
    print json.loads(v)

专 员

payload
{u forced : False, u compare : u https://github.com/gonvaled/...1420937 , ... 
 u before : u 14209371dcbdd95cc3ef5c4a07d80edd42f1295c }




相关问题
Can Django models use MySQL functions?

Is there a way to force Django models to pass a field to a MySQL function every time the model data is read or loaded? To clarify what I mean in SQL, I want the Django model to produce something like ...

An enterprise scheduler for python (like quartz)

I am looking for an enterprise tasks scheduler for python, like quartz is for Java. Requirements: Persistent: if the process restarts or the machine restarts, then all the jobs must stay there and ...

How to remove unique, then duplicate dictionaries in a list?

Given the following list that contains some duplicate and some unique dictionaries, what is the best method to remove unique dictionaries first, then reduce the duplicate dictionaries to single ...

What is suggested seed value to use with random.seed()?

Simple enough question: I m using python random module to generate random integers. I want to know what is the suggested value to use with the random.seed() function? Currently I am letting this ...

How can I make the PyDev editor selectively ignore errors?

I m using PyDev under Eclipse to write some Jython code. I ve got numerous instances where I need to do something like this: import com.work.project.component.client.Interface.ISubInterface as ...

How do I profile `paster serve` s startup time?

Python s paster serve app.ini is taking longer than I would like to be ready for the first request. I know how to profile requests with middleware, but how do I profile the initialization time? I ...

Pragmatically adding give-aways/freebies to an online store

Our business currently has an online store and recently we ve been offering free specials to our customers. Right now, we simply display the special and give the buyer a notice stating we will add the ...

Converting Dictionary to List? [duplicate]

I m trying to convert a Python dictionary into a Python list, in order to perform some calculations. #My dictionary dict = {} dict[ Capital ]="London" dict[ Food ]="Fish&Chips" dict[ 2012 ]="...

热门标签