list和dict的表示
程序员文章站
2022-04-28 20:09:21
...
list列表用[ ]表示:
>>> things = ['a','b','c','d']
>>> print(things[1])
b
>>> things[1] = 'z'
>>> things
['a','z','c','d']
字典dict用{ }表示:
>>> stuff = {'name':'Zed', 'age':39, 'height': 6*12+2}
>>> print(stuff['age'])
Zed
>>> stuff['city'] = 'SF'
>>> print(stuff['city'])
SF
推荐阅读
-
Python中字典(dict)和列表(list)的排序方法实例
-
Python把csv数据写入list和字典类型的变量脚本方法
-
python基础教程:dir()和__dict__属性的区别
-
在Python中使用dict和set方法的教程
-
php通过explode()和list()函数实现字符串的截取
-
把1316这个数表示成两个数的和,其中一个为13的倍数,另一个是11的倍数,求这两个数。_PHP教程
-
Java基础学习总结(129)——Arrays.asList得到的List进行add和remove等操作出现异常解析
-
Java Collections.sort()实现List排序的默认方法和自定义方法
-
C# 字符串、数组和List的截取和转换实例
-
Java Collections.sort()实现List排序的默认方法和自定义方法