首页
注册
登录
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
V2EX
›
Python
Python 中如何判断一个值是否能被 Parse
lm902
·
lm902
·
2014 年 5 月 27 日
· 3957 次点击
这是一个创建于 4249 天前的主题,其中的信息可能已经有所发展或是发生改变。
例如C#中int.Parse("2")返回2,int.TryParse("2")返回true,int.Parse("a")抛出异常,int.TryParse("a")返回false而不会抛出异常
我想知道Python中有哪个方法是类似于上面所说int.TryParse的,找半天没找到
返回
异常
例如
1 条回复
1
aec4d
2014 年 5 月 27 日
isinstance(2,int),不抛出异常捕获异常处理就可以
关于
·
帮助文档
·
自助推广系统
·
博客
·
API
·
FAQ
·
Solana
·
5255 人在线
最高记录 6679
·
Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 25ms ·
UTC 05:46
·
PVG 13:46
·
LAX 21:46
·
JFK 00:46
♥ Do have faith in what you're doing.
❯