我想在Python腳本中執行一些自動操作,並且遇到問題。我正在嘗試執行POST到服務器。在Python中的POST請求中傳遞'+'字符
url = 'http://www.example.com'
params = {'arg0': 'value', 'arg1': '+value'}
f = urllib.urlopen(url, urllib.urlencode(params))
print f.read()
我也做了相當的瀏覽器操作,其中第二ARG,arg1
作爲+value
過去了,但是當我與Python做了+
被改爲%2B
的Wireshark的捕獲,即
Line-based text data: application/x-www-form-urlencoded
arg0=value&arg1=%2Bvalue
當它應該是:
Line-based text data: application/x-www-form-urlencoded
arg0=value&arg1=+value
我也用了請求模塊,它似乎s做同樣的事情。
url = 'http://www.example.com'
params = {'arg0': 'value', 'arg1': '+value'}
f = requests.post(url, params)
谷歌是不是你的朋友,當你有涉及到「+」的問題,因爲它似乎是所有這麼多別的一個問題。
您使用的是什麼版本的請求? – root
我今天做了一個pip安裝請求 - 0.14.0 –
「當你遇到與'+'相關的問題時,Google不是你的朋友」 - 對於搜索特殊字符,有特殊的搜索引擎,如http://symbolhound.com/ – l4mpi