V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
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 · 2017-07-17 11:59:31 +08:00 · 2072 次点击
    这是一个创建于 2492 天前的主题,其中的信息可能已经有所发展或是发生改变。
    #%%
    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()
    目前尚无回复
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   1243 人在线   最高记录 6547   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 23:11 · PVG 07:11 · LAX 16:11 · JFK 19:11
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.