手机
当前位置:查字典教程网 >脚本专栏 >python >python实现给数组按片赋值的方法
python实现给数组按片赋值的方法
摘要:本文实例讲述了python实现给数组按片赋值的方法。分享给大家供大家参考。具体如下:这段代码可以直接给数组的第5-7个元素赋值invento...

本文实例讲述了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 开发Activex组件方法

python去掉字符串中重复字符的方法

python实现apahce网站日志分析示例

Python实现的Kmeans++算法实例

python调用shell的方法

Python 返回汉字的汉语拼音

python 不关闭控制台的实现方法

python赋值操作方法分享

Python实现扫描指定目录下的子目录及文件的方法

python实现的二叉树算法和kmp算法实例

精品推荐
分类导航