官术网_书友最值得收藏!

Post colon

Now if I put the colon on the other side of the 3, that says I want everything after 3, so 3 and after. If I say x[3:], that's giving me the third element, 0, 1, 2, 3, and everything after it. So that's going to return 4, 5, and 6 in that example, OK?

x[3:]

The output is as follows:

[4, 5, 6]

You might want to keep this IPython/Jupyter Notebook file around. It's a good reference, because sometimes it can get confusing as to whether the slicing operator includes that element or if it's up to or including it or not. So the best way is to just play around with it here and remind yourself.

主站蜘蛛池模板: 九龙坡区| 湾仔区| 河池市| 武冈市| 石楼县| 阿尔山市| 息烽县| 石景山区| 巨鹿县| 普兰店市| 青阳县| 贞丰县| 天柱县| 大邑县| 临夏县| 富平县| 洱源县| 双柏县| 商丘市| 富阳市| 大埔县| 乡城县| 洞口县| 阜康市| 个旧市| 始兴县| 长兴县| 牙克石市| 乌拉特前旗| 庄河市| 湾仔区| 化德县| 安岳县| 南通市| 湘阴县| 会宁县| 德阳市| 巴林左旗| 洪泽县| 沅江市| 曲松县|