Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 1585

Python • Parsing string

$
0
0
I have a data string from an HTML form using the GET method as below, the string obtained by the Python script os.environ.get('QUERY_STRING')

name=sam&comment=sam+comment&answer=red&question_no=3&submit=Submit

Can anyone give me some guidance as to how to parse this string in Python so I can have a variable 'name 'with value 'sam', variable 'comment ' with value 'sam comment' etc? My first thoughts are to read each character in turn until I find a separating character (eg = or &) and then extract the data that follows. is there an easier way?

Statistics: Posted by Duggieb — Mon Oct 13, 2025 7:07 pm



Viewing all articles
Browse latest Browse all 1585

Trending Articles