这是我的代码:
cj = cookielib.CookieJar()
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
urllib2.install_opener(opener)
opener.add_data(json_data) #runtime error on this line
r = None
try:
r = opener.open(config.get_url())
except urllib2.HTTPError as e:
print "..."
我收到运行时错误:opener.add_data(get_json) AttributeError: OpenerDirector instance has no attribute 'add_data'
如何向此请求添加请求 json 数据?