推荐学习书目
› 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 · 3612 views
    This topic created in 3832 days ago, the information mentioned may be changed or developed.
    ![]( )

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

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

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


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

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