Hi, Im just starting development in PyQT, and I have quite a basic thing i'm trying to do which I would find quite easy using something like PHP, but i'm struggling with python. Not sure if im posting in correct place.. but Basically I have a string like the following: name:Example; link:www.google.com; datetime:20100209 | name:Example2; link:www.yahoo.co.uk; datetime:20090808 So each result is seperated by a pipe (|) and key value pairs are seperated by a semi colon, then by a colon. I want the ability to put these in to some kind of array so I can create a results page with lets say the following: Result 1 Name: Example Link: www.google.com Datetime: 20100209 Result 2 Name: Example2 Link: www.yahoo.co.uk Datetime: 20090808 Could someone help me with this snippet? Thanks
for result in data.split("|"): for line in result.split("\n"): idx = line.find(":") key = line[:idx] value = line[idx + 1:] print "%s: %s" % (key, value)