V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
推荐学习书目
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 · Aug 4, 2017 · 2250 views
    This topic created in 3187 days ago, the information mentioned may be changed or developed.

    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

    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2961 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 00:29 · PVG 08:29 · LAX 17:29 · JFK 20:29
    ♥ Do have faith in what you're doing.