urllib2 and json

后端 未结 6 737
北恋
北恋 2020-11-29 00:58

can anyone point out a tutorial that shows me how to do a POST request using urllib2 with the data being in JSON format?

6条回答
  •  时光说笑
    2020-11-29 01:39

    Example - sending some data encoded as JSON as a POST data:

    import json
    import urllib2
    data = json.dumps([1, 2, 3])
    f = urllib2.urlopen(url, data)
    response = f.read()
    f.close()
    

提交回复
热议问题