python中生成字典
作者:互联网
1、
>>> a = {"a":111,"b":222,"c":333,"d":444} >>> a {'a': 111, 'b': 222, 'c': 333, 'd': 444} >>> len(a) 4 >>> type(a) <class 'dict'>
2、
>>> a = dict((("a",111),("b",222),("c",333),("d",444))) >>> a {'a': 111, 'b': 222, 'c': 333, 'd': 444} >>> len(a) 4 >>> type(a) <class 'dict'>
3、
>>> a = dict(a = 111, b = 222, c = 333, d = 444) >>> a {'a': 111, 'b': 222, 'c': 333, 'd': 444} >>> len(a) 4 >>> type(a) <class 'dict'>
4、
>>> a = {} >>> a["a"] = 111 >>> a["b"] = 222 >>> a {'a': 111, 'b': 222} >>> len(a) 2 >>> type(a) <class 'dict'>
标签:python,333,生成,111,len,444,type,222,字典 来源: https://www.cnblogs.com/liujiaxin2018/p/14449331.html