python基本数据类型 Python:popitem()不是说删除并返回任意的(key?

Python:popitem()不是说删除并返回任意的(key?文档说“Remove and return an arbitrary (key, value) pair from the dictio

Python:popitem()不是说删除并返回任意的(key?

文档说“Remove and return an arbitrary (key, value) pair from the dictionary.”arbitrary不是随机的意思,arbitrary的意思是由python决定的一个item,而不是像pop一样是由你决定的item。文档这句话是告诉你,你不能假定认定python一定会按某个顺序返回给你一个item。

python中的pop怎么使用?

年轻人认真一点好不好words=“all good things comes to those who wait."words 是字符串 ,它怎么有pop的方法?------------------------------------>>> a=[1,2,3,4]>>> a.pop(0)1>>> a[2, 3, 4]>>> a.pop(-1)4>>> a[2, 3]>>> 自己搞个数组 pop 几下就知道了