Python学习记录

Zip 函数可以进行多个list的迭代  

for price, info, total_deal, seller, location in zip(prices, infos, total_deals, sellers, locations):
    products = {
        'price': price,
        'info': info.strip(),
        'total_deal': total_deal,
        'seller': seller.strip(),
        'location': location,
    }
    print(products)

将几个list的元素合并为一个list的方法  使用extend
A = [1,2,3]
B = [3,4,5]
A.extend(B)
或者直接相加
A + B = 一个新的list

因为学习爬虫需要redis和MongoDB
启动redis  先进入redis路径 再启用redis-server
然后就开启了redis
启动MongoDB 先进入MongoDB的路径 然后再sudo mongod 即可

你可能感兴趣的:(Python)