2017年7月28日 星期五

[Python2]Magic operate in List type

Recently I found a nice operator in Python list

# code :
a_simple_array = [1, 2, 3, 4, 5, 6]
a_simple_array[::2] = ('one', 'three', 'five')
print a_simple_array
#
# result :
['one', 2, 'three', 4, 'five' 6]
# End code

原來Python 的Array 可以這樣子去Insert! Magic...



沒有留言:

張貼留言