search

Home  >  Q&A  >  body text

python 字典循环添加问题

quhao=(requ.findall(href))[0]
    i=0
    for jiage in jiagep:
        #过滤面议价格
        if jiage.b.string=='面议':
            continue
        quhao={}
        quhao[i]=jiage.b.string
        i=i+1
    print(str(quhao))

现在每次只能添加最后一位
{76: '2600'}
{96: '2500'}
{74: '3300'}
{105: '2550'}
{81: '2600'}
{64: '1700'}
{67: '1800'}
{68: '1700'}
{61: '2100'}

这个外面还有一层for循环 目的就是创建不同的字典

阿神阿神2781 days ago564

reply all(1)I'll reply

  • ringa_lee

    ringa_lee2017-04-18 10:21:24

    quhao={} put it outside for

    reply
    0
  • Cancelreply