python 提交post数据求助
#coding:utf-8importjsonimportrequestsdef_put_tickets(item_id,username,password,oid,ti...
# coding:utf-8
import json
import requests
def _put_tickets(item_id, username, password, oid, tickets, active):
params = {
'item_id': item_id,
'username': username,
'password': password,
'oid': oid,
'tickets': tickets,
'active': active,
}
print 'item_id='+item_id[-8:]+'&username='+ username +'&password=”'+ password+'&oid='+ oid+'&tickets='+tickets + '&active=”' +str(active)
r = requests.post('http://www.czctzc.com/admin/Ajax.ashx?action=upInfo', 'item_id='+item_id[-8:]+'&username='+ username +'&password=”'+ password+'&oid='+ oid+'&tickets='+tickets + '&active=”' +str(active))
print 'item_id='+item_id[-8:]+'&username='+ username +'&password=”'+ password+'&oid='+ oid+'&tickets='+tickets + '&active=”' +str(active),r
return r == u'成功加入{1}'
def put_tickets(item_id, username, password, oid, tickets, active):
for _ in xrange(4):
try:
return _put_tickets(item_id, username, password, oid, tickets, active)
except Exception:
print u'提交错误,重试中....测试版'
调用 put_tickets 结果总是 提交错误 请问k哪里错了。 展开
import json
import requests
def _put_tickets(item_id, username, password, oid, tickets, active):
params = {
'item_id': item_id,
'username': username,
'password': password,
'oid': oid,
'tickets': tickets,
'active': active,
}
print 'item_id='+item_id[-8:]+'&username='+ username +'&password=”'+ password+'&oid='+ oid+'&tickets='+tickets + '&active=”' +str(active)
r = requests.post('http://www.czctzc.com/admin/Ajax.ashx?action=upInfo', 'item_id='+item_id[-8:]+'&username='+ username +'&password=”'+ password+'&oid='+ oid+'&tickets='+tickets + '&active=”' +str(active))
print 'item_id='+item_id[-8:]+'&username='+ username +'&password=”'+ password+'&oid='+ oid+'&tickets='+tickets + '&active=”' +str(active),r
return r == u'成功加入{1}'
def put_tickets(item_id, username, password, oid, tickets, active):
for _ in xrange(4):
try:
return _put_tickets(item_id, username, password, oid, tickets, active)
except Exception:
print u'提交错误,重试中....测试版'
调用 put_tickets 结果总是 提交错误 请问k哪里错了。 展开
1个回答
展开全部
这又不知道 你的def put_tickets(item_id, username, password, oid, tickets, active函数里面的参数到底是怎么样子的
你把
try:
return _put_tickets(item_id, username, password, oid, tickets, active)
except Exception:
print u'提交错误,重试中....测试版'
这个加个print 语句
try:
return _put_tickets(item_id, username, password, oid, tickets, active)
except Exception,e:
print e #这里会打印异常原因
print u'提交错误,重试中....测试版'
或者直接把 try except 去掉 看看报错信息
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询