写了一个从网站批量下载图片的爬虫,其中保存图片的代码:
img_name = pq(picHTML.text).find('.main-image').find('img').attr('alt')//图片的名字
f = open(img_name+'.jpg','ab')
老是报:
invalid mode ('ab') or filename: u'u5939u4e00u4e0bu53efu597d? u65e5u672cu6027u611fu5973u795eu4e2du6751u9759u9999u5927u79c0u7206u4e73 Fu7ea7u8089u5f39u80f8u608du65e0u6bd4.jpg'
的错,求找到原因?
Forgive me for being ignorant. What is the mode of ab? Add content from end of file? I think wb is fine.