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
he458361789
V2EX  ›  Python

Python pool.map 返回的结果 在遍历过程报错了 UnboundLocalError: local variable 'results' referenced before assignment

  •  
  •   he458361789 · 2017-08-04 15:54:26 +08:00 · 1726 次点击
    这是一个创建于 2463 天前的主题,其中的信息可能已经有所发展或是发生改变。

    python 代码 def xc(list_url,filename): urls = wz_url(list_url) pool = ThreadPool(10) # 设置线程数 try: results = pool.map(wz_content, urls) # 开始跑数据 except Exception, e: print '\033[1;31m 报错信息:\033[0m' + str(e) pool.close() pool.join() # 4 行代码结束 for result in results: filename.write(result + '\n') filename.close()

    报错信息 Traceback (most recent call last): File "laonanren.py", line 105, in <module> xc(k,v) File "laonanren.py", line 80, in xc for result in results: UnboundLocalError: local variable 'results' referenced before assignment

    目前尚无回复
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2309 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 03:21 · PVG 11:21 · LAX 20:21 · JFK 23:21
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.