摘要:
001、 >>> test1 = dict(a = 100, b = 200, c = 300, d = 400) >>> test1 {'a': 100, 'b': 200, 'c': 300, 'd': 400} >>> test2 = dict() >>> for i,j in test1.i 阅读全文
摘要:
001、 >>> test1 = ["aaa", "bbb", "ccc", "ddd"] >>> test1 ['aaa', 'bbb', 'ccc', 'ddd'] >>> '_'.join(test1) ## 列表转换为字符串 'aaa_bbb_ccc_ddd' >>> test2 = '_' 阅读全文
摘要:
001、 >>> test1 = dict(c = 500, a = 300, b = 200, e = 600, d = 777) >>> test1 {'c': 500, 'a': 300, 'b': 200, 'e': 600, 'd': 777} >>> test2 = dict() >>> 阅读全文
摘要:
001、排序 a、 >>> test = [8, 2, 5, 9, 3] >>> test [8, 2, 5, 9, 3] >>> test.sort() ## 直接在原始列表中排序 >>> test [2, 3, 5, 8, 9] >>> test = [8, 2, 5, 9, 3] >>> te 阅读全文
摘要:
001、 >>> dict1 = {} >>> dict1 {} >>> dict2 = dict() >>> dict2 {} 002、fromkeys创建 >>> dict1 = {} >>> dict1 {} >>> dict1.fromkeys(['a', 'b', 'c']) ## 值为空 阅读全文
摘要:
001、复制方式1 >>> dict1 = dict(a = 100, b = 200, c = 300, d = 400) >>> dict1 {'a': 100, 'b': 200, 'c': 300, 'd': 400} >>> dict2 = dict1 ## 直接赋值, 原始字典变化,复制 阅读全文
摘要:
001、 >>> dict1 = dict(a = 100, b = 200, c = 300, d = 400) >>> dict1 {'a': 100, 'b': 200, 'c': 300, 'd': 400} >>> dict1['e'] = 500 ## 添加元素e >>> dict1 { 阅读全文
摘要:
001、del删除 >>> dict1 = dict(a = 100, b = 200, c = 300, d = 400) >>> dict1 {'a': 100, 'b': 200, 'c': 300, 'd': 400} >>> del dict1['b'] ## 删除元素b >>> dict 阅读全文