I am working with the web scraping framework Scrapy and I am a bit of a noob when it comes to python. So I am wondering how do I iterate over all of the scraped items which
What you should note is that lstrip() returns a copy of the string rather than modify the object. To actually update your dictionary, you'll need to assign the stripped value back to the item.
For example:
for k, v in your_dict.iteritems():
your_dict[k] = v.lstrip()
Note the use of .iteritems()
which returns an iterator instead of a list of key value pairs. This makes it somewhat more efficient.
I should add that in Python3, .item() has been changed to return "views" and so .iteritems()
would not be required.