Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我发现 from 语句li = str.split(),一个元素列表被分配给li ,而 from li = li.insert(2, "whatever"),它实际上什么也没得到,li第二个语句之后的列表中没有任何值。为什么这两者有区别?
li = str.split()
li
li = li.insert(2, "whatever")
li.insert不返回但修改 li:
li.insert
s = "foo bar baz" l = s.split() l == ['foo', 'bar', 'baz'] l.insert(2, "qux") l == ['foo', 'bar', 'qux', 'baz']