Python 2.x gotchas and landmines

后端 未结 23 2347
北恋
北恋 2020-11-28 17:47

The purpose of my question is to strengthen my knowledge base with Python and get a better picture of it, which includes knowing its faults and surprises. To keep things sp

23条回答
  •  盖世英雄少女心
    2020-11-28 18:20

    The values of range(end_val) are not only strictly smaller than end_val, but strictly smaller than int(end_val). For a float argument to range, this might be an unexpected result:

    from future.builtins import range
    list(range(2.89))
    [0, 1]
    

提交回复
热议问题