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
python3 中 -123 // 10 = ?
chenstack
·
Mar 28, 2020
· 4199 views
This topic created in 2411 days ago, the information mentioned may be changed or developed.
平时很少用到,一直记成整除,刷 leetcode 才重新记得 //运算符是向下取整,-123 // 10 结果是-13 。
python 里面要像 C++那样整除是不是只能 int(-123 / 10)?但经过了浮点数转换总觉得效率不够高,有没有更好的方法?
整除
leetcode
Python
Python3
4 replies
•
2020-03-29 21:45:16 +08:00
metamask
Mar 28, 2020
1
math.ceil(-123/10)
123444a
Mar 28, 2020 via Android
2
像 0 取整,向负无穷取整
aloxaf
Mar 28, 2020
3
-(123 // 10) (
asche910
Mar 29, 2020
4
明确正数的话直接 // ,负数取整我看别人基本上都是 float 转换 int 。不过都用 python 了,感觉更注重的是简洁方便吧,速度还是算了。
About
·
Help
·
Advertise
·
Blog
·
API
·
FAQ
·
Privacy
·
Solana
·
1584 Online
Highest 6679
·
Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 51ms ·
UTC 23:06
·
PVG 07:06
·
LAX 15:06
·
JFK 18:06
♥ Do have faith in what you're doing.
❯