扫码关注官方订阅号
字符串或者数组 []和冒号组合, 如[1:], [-1:] 等等各种组合,有没有同学能详细说说这中用法
业精于勤,荒于嬉;行成于思,毁于随。
这个比较基础,可以看看这里的介绍http://techearth.net/python/index.php...
按照上图理解.会很容易.
a='hello'
a[1:3]即图中的1到3之间的段'el'
a[-1:-3]即'll'
特别的:start和end取空的时候,意指取尽可能长
[:]应该是和深浅拷贝有关
a = [1, 2, 3] b = a b[0] = 9 print a print b c = b[:] c[0] = 11 print b print c
微信扫码关注PHP中文网服务号
QQ扫码加入技术交流群
扫描下载App
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
PHP学习
技术支持
返回顶部
这个比较基础,可以看看这里的介绍
http://techearth.net/python/index.php...
按照上图理解.会很容易.
a='hello'
a[1:3]即图中的1到3之间的段'el'
a[-1:-3]即'll'
特别的:start和end取空的时候,意指取尽可能长
[:]应该是和深浅拷贝有关