推荐学习书目
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
webjin
V2EX  ›  Python

算术问题?

  •  
  •   webjin · Nov 7, 2014 · 2548 views
    This topic created in 4205 days ago, the information mentioned may be changed or developed.
    >>2**8
    结果256
    那反过来去算多少次方等于256
    4 replies    2014-11-08 00:19:12 +08:00
    aaaa007cn
        1
    aaaa007cn  
       Nov 7, 2014
    用对数
    log(a^b) = b * log(a)
    staticor
        2
    staticor  
       Nov 7, 2014   ❤️ 1
    import math
    print math.log(64,2)

    # math.log(x, base)
    webjin
        3
    webjin  
    OP
       Nov 7, 2014
    @staticor 谢谢。 这个是第三方模块还是?
    staticor
        4
    staticor  
       Nov 8, 2014
    @webjin 这个是自带的. 不用安装了.
    对数函数和三角函数的使用频率要远远低于 加减等, 甚至是没abs 常用
    其实就是没abs(绝对值函数)常用, 所以不用math.abs.

    把log对数函数放在math蝇一好处:
    另外对数函数 logarithm 如果用前三位log 作对数与 日志函数 .log 会出现混淆 所以放在math模块是个明确选择.
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5925 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 36ms · UTC 03:26 · PVG 11:26 · LAX 20:26 · JFK 23:26
    ♥ Do have faith in what you're doing.