python爬虫的各种存储方式之txt
简单下载一个图片:
from urllib import request
url="http://pic.netbian.com/uploads/allimg/180912/221007-15367614072cc2.jpg"
request.urlretrieve(url,"冰岛瀑布.jpg") #下载和存放
存入txt
判断目录,有则打开,没有新建
import os
if os.path.exists('D:\Python\代码\数据爬取'):
os.chdir('D:\Python\代码\数据爬取')