将值快速附加到列表中 [英] Quickly append value to a list
本文介绍了将值快速附加到列表中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
PHP有一个非常快速的方法来附加一个数组:
PHP has a really quick way to append a value to an array:
$array[] = 'value';
在python中最简单的方法是什么,而不需要索引号?
另外,有一个简单的方法来做一个嵌套在一个字典里面的列表,像这样的PHP等价物。
What is the easiest way to do this in python without needing an index number? Also, is there an easy way to do this with a list nested inside a dictionary, like this PHP equivalent..
$array['associative'][] = 'value';
推荐答案
my_list.append(value)
或
my_dict[key].append(value)
这篇关于将值快速附加到列表中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文