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

为啥不一样?

  •  
  •   yumijie · Jun 2, 2016 · 3186 views
    This topic created in 3645 days ago, the information mentioned may be changed or developed.
    ![]( )

    python 语法中的双引号,单引号
    15 replies    2016-06-03 11:42:18 +08:00
    mdzz
        1
    mdzz  
       Jun 2, 2016
    Python 又不是 JavaScript : doge :
    am241
        2
    am241  
       Jun 2, 2016
    >>> bool('')
    False
    dphdjy
        3
    dphdjy  
       Jun 2, 2016 via Android
    你把 0 换成 1 就一样了 XD
    kindjeff
        4
    kindjeff  
       Jun 2, 2016
    因为他是这么规定的
    newghost
        5
    newghost  
       Jun 2, 2016
    这是实站派做出的语言

    字符的真假定义为: 有字符为真,无字符为假,所以'0'为真
    数字是无值( 0 )为假
    billlee
        6
    billlee  
       Jun 2, 2016
    Python 是强类型
    qqmishi
        7
    qqmishi  
       Jun 2, 2016
    http://i4.buimg.com/666a5c7d9cf86538.png

    我猜你应该没预料到这种情况。
    Python 规定了任何非 0 和非 null 值均为 True 。
    FrankFang128
        8
    FrankFang128  
       Jun 3, 2016 via Android
    JS 也不一样啊
    alexapollo
        9
    alexapollo  
       Jun 3, 2016
    Python 这个处理已经非常好了。
    没有见识过 Scala 的不知道什么是坑 —— 它会接收 "true" / "false" / "1" / "0" / "y" / "n" / "t" 等等类似的字符串,映射为定义好的 bool 值。
    不知道这个细节的人怎么死的都不知道 —— 正常情况下大部分的字符串它都会返回 false ,只有这些特殊的例外
    onlyice
        10
    onlyice  
       Jun 3, 2016


    P.S. Learning Python 是一本不错的参考书
    di94sh
        11
    di94sh  
       Jun 3, 2016 via iPhone
    一个是字符一个是字符串,黑呀,我只会 c
    goodan
        12
    goodan  
       Jun 3, 2016
    lz 上一个帖子也是 python 。。
    找本书系统的敲一遍吧
    araraloren
        13
    araraloren  
       Jun 3, 2016
    ~~突然变成了,小学生集中营 。。
    lerry
        14
    lerry  
       Jun 3, 2016
    比 js 好

    Boolean([])
    true
    jy02201949
        15
    jy02201949  
       Jun 3, 2016
    真的变成小学生集中营了,就不能好好 google 一下吗,不行上 bing ,再不济 baidu 也行啊
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2662 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 68ms · UTC 15:37 · PVG 23:37 · LAX 08:37 · JFK 11:37
    ♥ Do have faith in what you're doing.