为什么 myList[1:] = “world”和 myList[1:] = [“world”]的结果不一样?
資深大佬 : JQiue 4
假设有一个列表 myList = ['hello', 1, 2, 3, 4]
如果 myList[1:] = "world"
则得到['hello', 'w', 'o', 'r', 'l', 'd']
如果 myList[1:] = ["world"]
则会得到['hello', 'world']
这是为什么呢?
大佬有話說 (6)