jf009

导航

python中创建列表、元组、字符串、字典

>>> a = ["aaa","bbb","ccc"]  ## 列表,中括号,逗号
>>> type(a)
<class ‘list‘>
>>> b = ("aaa","bbb","ccc")   ## 元组,小括号,逗号
>>> type(b)
<class ‘tuple‘>
>>> c = "aaabbbccc"       ## 字符串,引号
>>> type(c)
<class ‘str‘>
>>> d = {"a":"aaa","b":"bbb","c":"ccc"}   ## 字典,大括号,冒号,逗号 ,键值对(当普通索引不好用时用字典)
>>> type(d)
<class ‘dict‘>

  

posted on 2021-02-26 18:49  jf009  阅读(70)  评论(0编辑  收藏  举报