0

If I have

qs = 'search=One+two+three&product=apple'

How do I add '+four' to search param? qs can have an unknown number of parameters.

SuperShoot
  • 9,880
  • 2
  • 38
  • 55
bayman
  • 1,579
  • 5
  • 23
  • 46
  • 1
    The duplicate covers the second half of this problem (reassembling into a string), but the question shows the first half. And the answers show an example of parsing and reassembling. – Daniel Pryden Mar 28 '19 at 01:41
  • The duplicate is somewhat misleading, and some digging is required to actually get the desired solution. OP, see [`urllib.parse.parse_qs`](https://docs.python.org/3/library/urllib.parse.html#urllib.parse.parse_qs). – iz_ Mar 28 '19 at 01:43
  • new = qs [:qs.index ("&")] + "+four" + qs [qs.index ("&"):] – bashBedlam Mar 28 '19 at 02:23

0 Answers0