对于发布请求的正文我试图转:
data = [
('p1', 'true'),
('table', 'f3'),
('ids', '/'R000000020/'')
]
进入
p1=true&table=f3&ids='R000000020'
使用
import urllib
payload = urllib.urlencode(data)
但我正在
'p1=true&table=f3&ids=%27R000000020%27'
如何才能使其正常工作?
编辑:我最终使用了:
data = [
('p1', 'true'),
('table', 'f3'),
('ids', "'"+'R000000020'+"'")
]
答案 0 :(得分:1)
Urlencode会将using (IDbConnection connection = new System.Data.SqlClient.SqlConnection(SQLHelper.CnnCal("OADB")))
{
IDbCommand command = connection.createCommand();
command.CommandText = $"SELECT COUNT(SOURCEID) AS 'MYCOUNT' "
+ "FROM [OADB].[oadb].[CmsCallHistory] "
+ "WHERE disposition = 2 and DISPSPLIT in (" + SkillNumber + ") AND SEGSTOP BETWEEN '" +
fixedStartDate + "' and '" + fixedEndDate + "'";
return (string)command.ExecuteScalar();
}
编码为'
。如果您不想这样,可以手动加入%27
:
data
或者您可以将payload = '&'.join(['='.join(d) for d in data])
替换为%27
:
'
答案 1 :(得分:0)
我知道这听起来很愚蠢,但您已将数据ids
更改为:
('ids', 'R000000020')