Iterating over a dictionary in python and stripping white space -



Iterating over a dictionary in python and stripping white space -

i working web scraping framework scrapy , bit of noob when comes python. wondering how iterate on of scraped items seem in dictionary , strip white space each one.

here code have been playing in item pipeline.:

for info in item: info[info].lstrip()

but code not work, because cannot select items individually. tried this:

for key, value item.items(): value[1].lstrip()

this sec method works degree, problem have no thought how loop on of values.

i know such easy fix, cannot seem find it. help appreciated. :)

not direct reply question, suggest @ item loaders , input/output processors. lot of cleanup can take care of here.

an illustration strips each entry be:

class itemloader(itemloader): default_output_processor = mapcompose(unicode.strip)

python dictionary whitespace scrapy

Comments

Popular posts from this blog

How do I check if an insert was successful with MySQLdb in Python? -

delphi - blogger via idHTTP : error 400 bad request -

postgresql - ERROR: operator is not unique: unknown + unknown -