Why would you open an xml file in binary mode for editing in Python?
According to Pydocs,
fp = file('blah.xml', 'w+b')
or
fp = file('blah.xml', 'wb')
means open the file in write and binary mode. This is an xml file, however, so why do these two chaps
http://www.pixelmender.com/2010/10/12/scraping-data-using-scrapy-framework/ and http://doc.scrapy.org/topics/exporters.html#scrapy.contrib.exporter.XmlItemExporter
recommend 开发者_StackOverflow中文版doing so in their tutorial/docs pages about exporting Scrapy items? In other words, why would anyone open a new xml file in 'b' mode?
It just doesn't make sense with plain XML files. On Unix there is no difference between binary and non-binary. On Windows written '\n' get translated to '\r\n' if you write non-binary.
But it will make a difference if you embed binary BLOBs, but I don't see those on the sites you mentioned.
精彩评论