python中的quote_plus()如何使得转译后的为小写?

如题,现在转译后的结果为
%2Fkns%2Fbrief%2Fbrief.aspx%3Fcurpage%3D17%26RecordsPerPage%3D20%26QueryID%3D0%26...

请问有什么办法可以将%2F变为%2f呢?


慕桂英4014372
浏览 773回答 1
1回答

月关宝盒

In [1]: '%2Fkns%2Fbrief%2Fbrief.aspx%3Fcurpage%3D17%26RecordsPerPage%3D20%26QueryID%3D0%26'.lower() Out[1]: '%2fkns%2fbrief%2fbrief.aspx%3fcurpage%3d17%26recordsperpage%3d20%26queryid%3d0%26'In [2]: import re In [3]: regex = re.compile(r'%\d{1}[A-Z]{1}') In [4]: _ = '%2Fkns%2Fbrief%2Fbrief.aspx%3Fcurpage%3D17%26RecordsPerPage%3D20%26QueryID%3D0%26'In [5]: res = regex.findall(_) In [6]: res Out[6]: ['%2F', '%2F', '%2F', '%3F', '%3D', '%3D', '%3D'] In [7]: for i in res:    ...:     _ = _.replace(i, i.lower())    ...: In [8]: _ Out[8]: '%2fkns%2fbrief%2fbrief.aspx%3fcurpage%3d17%26RecordsPerPage%3d20%26QueryID%3d0%26'
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Python