JavaScript中的urllib.quote_plus()等效项
尝试从Python移植代码片段:JavaScript中的urllib.quote_plus()等效项,javascript,python,urlencode,urllib,Javascript,Python,Urlencode,Urllib,尝试从Python移植代码片段: my_input = "this&is£some text" encoded_input = urllib.quote_plus(str(my_input)) …到JavaScript: var my_input = "this&is£some text"; encoded_input = encodeURIComponent(my_input); 小的区别是urllib.quote_plus()将把空格转换为+,而不是%20。 只是想知道是
my_input = "this&is£some text"
encoded_input = urllib.quote_plus(str(my_input))
…到JavaScript:
var my_input = "this&is£some text";
encoded_input = encodeURIComponent(my_input);
小的区别是urllib.quote_plus()
将把空格转换为+
,而不是%20
。
只是想知道是否有人能提供一些想法。
目前正在进行此
var my_input = "this&is£some text";
encoded_input = encodeURIComponent(my_input).replace(/%20/g,'+');
在Python代码中使用而不是
quote\u plus()
。如果更改Python代码不是一个解决方案,那么您选择将%20
替换为+
是首选方法()。好的,我会坚持我正在做的。由于提供了参考链接,因此接受此选项。