推荐学习书目
› Learn Python the Hard Way
Python Sites
› PyPI - Python Package Index
› http://diveintopython.org/toc/index.html
› Pocoo
值得关注的项目
› PyPy
› Celery
› Jinja2
› Read the Docs
› gevent
› pyenv
› virtualenv
› Stackless Python
› Beautiful Soup
› 结巴中文分词
› Green Unicorn
› Sentry
› Shovel
› Pyflakes
› pytest
Python 编程
› pep8 Checker
Styles
› PEP 8
› Google Python Style Guide
› Code Style from The Hitchhiker's Guide
miao009
V2EX  ›  Python

函数传参,及多线程处理问题, NameError: name 'i' is not defined,求各位大神帮忙找找问题呀,谢谢

  •  
  •   miao009 · Jul 17, 2017 · 2623 views
    This topic created in 3359 days ago, the information mentioned may be changed or developed.
    #%%
    def splist(l,s):
    lst = []
    lst =[l[i:i+s] for i in range(len(l)) if i%s == 0]
    return lst
    #%%

    def hansu (i,tokenlst):
    dict03 = {}

    for token in splist(tokenlst,1800)[i] :
    try:
    url02 = '''http://xxxxxx?token=%s&type=app_application'''%token
    resq = json.loads(requests.get(url02).text)['obj']
    df02 = pd.DataFrame(resq)
    dict03[token] = {'APP 个数':len(df02)}
    df05 = pd.DataFrame(dict03).T
    df05.to_excel('D:/维度 0716/APP 个数.xlsx')
    except:
    continue
    return df05


    threads = []
    for j in range(len(splist(tokenlst,1800))):
    t = threading.Thread(target=hansu,args=(j,tokenlst))
    threads.append(t)
    t.start()
    for t in threads:
    t.join()
    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   1028 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 21ms · UTC 23:26 · PVG 07:26 · LAX 16:26 · JFK 19:26
    ♥ Do have faith in what you're doing.