Home
Sign Up
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
V2EX
›
Python
关于 python 的 timeout 问题,超时即报错
nankingpython
·
May 30, 2016
· 4582 views
This topic created in 3822 days ago, the information mentioned may be changed or developed.
不管是全局 socket 的设置还是 urllib.request ( urllib2 )都是超时就报错退出程序, 有什么办法解决吗, 谢谢
超时
Python
urllib2
timeout
1 replies
jinxueliu
May 30, 2016
1
1
通过异常处理来解决
import socket
socket.setdefaulttimeout(10)
try:
....
except socket.timeout:
print('Error: time out')
About
·
Help
·
Advertise
·
Blog
·
API
·
FAQ
·
Privacy
·
Solana
·
2851 Online
Highest 6679
·
Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 23ms ·
UTC 04:19
·
PVG 12:19
·
LAX 20:19
·
JFK 23:19
♥ Do have faith in what you're doing.
❯