python 给数组按片赋值,这段代码可以直接给数组的4-6个元素赋值
inventory = ["sword", "armor", "shield", "healing potion"] inventory[4:6] = ["orb of future telling"] print inventory
python 给数组按片赋值,这段代码可以直接给数组的4-6个元素赋值
inventory = ["sword", "armor", "shield", "healing potion"] inventory[4:6] = ["orb of future telling"] print inventory