python实现给数组按片赋值的方法
2015-07-28 00:00
716 查看
本文实例讲述了python实现给数组按片赋值的方法。分享给大家供大家参考。具体如下:
这段代码可以直接给数组的第5-7个元素赋值
inventory = ["sword", "armor", "shield", "healing potion"] inventory[4:6] = ["orb of future telling"] print inventory
运行结果如下:
['sword', 'armor', 'shield', 'healing potion', 'orb of future telling']
希望本文所述对大家的Python程序设计有所帮助。
相关文章推荐
- python更新列表的方法
- python创建列表并给列表赋初始值的方法
- python列表操作之extend和append的区别实例分析
- python3抓取中文网页的方法
- Python3访问并下载网页内容的方法
- Python中的getopt函数使用详解
- Python中文竖排显示的方法
- Python中subprocess的简单使用示例
- Python实现批量转换文件编码的方法
- Python操作Word批量生成文章的方法
- python内置函数(三)
- [2015-07-27] python009
- [2015-07-26] python008
- [python]学习笔记2-字符串内建函数1
- python读取EXCLE文件数据
- python移动文件
- python中的set操作
- python获取内存和cpu利用率记录日志文件
- caffe python visualization程序解析
- python netwokx环境搭建