python 中没有i++!

 dic = {
'a':5,
'kelv':'ooo',
5:2333,
2333:'yoo'
}
print dic[dic[dic['a']]]
print dic #yoo
#{'a': 5, 'kelv': 'ooo', 5: 2333, 2333: 'yoo'} dic['sss']='ooooppppp'
print dic
#{'a': 5, 'kelv': 'ooo', 5: 2333, 'sss': 'ooooppppp', 2333: 'yoo'} step=0
dic ['b']=5
for key,value in sorted(dic.items()):
print key,"\t",value
step=step+1
print "step is "+str(step) '''
5 2333
2333 yoo
b 5
a 5
kelv ooo
sss ooooppppp
''' del dic['kelv']
print dic #{'a': 5, 'b': 5, 5: 2333, 'sss': 'ooooppppp', 2333: 'yoo'} for k in set(dic.values()):
print k '''
5
2333
ooooppppp
yoo
''' new_1 = {'A':'asss','B':'bssss','C':'asss','D':'bssss'}
new_2 = {'lll':'asss',123:'bssss','A':'asss','B':'bssss','C':'asss','D':'bssss'}
new_3 = {'Appp':'asss','B':'bs'}
arr = [new_1,new_2,new_3]
for a in arr[:3]:
a['A'] = ''
a['D'] = 'lllllllll'
print arr '''
[{'A': '1234', 'C': 'asss', 'B': 'bssss', 'D': 'lllllllll'}, {'A': '1234', 'C': 'asss', 'B': 'bssss', 'D': 'lllllllll', 'lll': 'asss', 123: 'bssss'}, {'A': '1234', 'B': 'bs', 'D': 'lllllllll', 'Appp': 'asss'}] '''
print arr[1].keys()
print arr[1].items()
#['A', 'C', 'B', 'D', 'lll', 123]
#[('A', '1234'), ('C', 'asss'), ('B', 'bssss'), ('D', 'lllllllll'), ('lll', 'asss'), (123, 'bssss')]
for a in arr:
for k,v in a.items():
print k,"\t",v '''
A 1234
C asss
B bssss
D lllllllll
A 1234
C asss
B bssss
D lllllllll
lll asss
123 bssss
A 1234
B bs
D lllllllll
Appp asss
'''
new_4={'kkkkk':{'opoppo':123}}
arr.append(new_4)
for value in arr[3].values():
for key2 in value:
print key2
#opoppo

字典|字典和数组嵌套|keys()|value()|item()|del的更多相关文章

  1. 记录我的 python 学习历程-Day05 字典/字典的嵌套

    一.字典的初识 为什么要有字典 字典与列表同属容器型数据类型,同样可以存储大量的数据,但是,列表的数据关联性不强,并且查询速度比较慢,只能按照顺序存储. 什么是字典 先说一下什么叫可变与不可变的数据类 ...

  2. go实现json数组嵌套

    go实现json数组嵌套 引用包 "encoding/json" 定义以下结构体 type person struct { Name string `json:"name ...

  3. js处理复杂数据格式数组嵌套对象,对象嵌套数组,reduce处理数据格式

    let list=[ {id:1,name:'a'}, {id:1,name:'b'}, {id:1,name:'c'}, {id:2,name:'A'}, {id:2,name:'B'}, {id: ...

  4. Leetcode 565.数组嵌套

    数组嵌套 索引从0开始长度为N的数组A,包含0到N - 1的所有整数.找到并返回最大的集合S,S[i] = {A[i], A[A[i]], A[A[A[i]]], ... }且遵守以下的规则. 假设选 ...

  5. localStorage中一个数组嵌套一个数组的怪相

    localStorage中一个数组嵌套一个数组的怪相 需求:向本地存储中循环添加对象 思路 : ​ 先完成点击事件中添加本地存储功能,当刷新时使用一个数组记录已经存储下来的数据,并在点击事件中将新生成 ...

  6. Java实现 LeetCode 565 数组嵌套(没有重复值的数组)

    565. 数组嵌套 索引从0开始长度为N的数组A,包含0到N - 1的所有整数.找到并返回最大的集合S,S[i] = {A[i], A[A[i]], A[A[A[i]]], - }且遵守以下的规则. ...

  7. [VBS]脚本中的字典、动态数组、队列和堆栈

    今天用VBS脚本写了几个程序,用到了字典(Dictionary).动态数组(ArrayList).队列(Queue)和堆栈(Stack).现在写篇Blog总结一下 :-) 1.编写环境 今天突发奇想下 ...

  8. swift基本用法-for循环遍历,遍历字典,循环生成数组

    // Playground - noun: a place where people can play import UIKit //--------------------------------- ...

  9. swift-for循环遍历,遍历字典,循环生成数组

    // Playground - noun: a place where people can play import UIKit //--------------------------------- ...

随机推荐

  1. python 中的os.path.split()函数用法

    基本概念   os.path.split()通过一对链表的头和尾来划分路径名.链表的tail是是最后的路径名元素.head则是它前面的元素. 举个例子: path name = '/home/User ...

  2. 一个例子搞清楚Java程序执行顺序

    当我们new一个GirlFriend时,我们都做了什么? 一个例子搞懂Java程序运行顺序 public class Girl { Person person = new Person("G ...

  3. 解决configure: error: C++ compiler cannot create executables问题

    参考 yum install gcc gcc++ 呵呵,这样的话还是有组件没有安装完整的.再执行一下这个命令就可以解决问题. yum install gcc gcc-c++ gcc-g77

  4. JavaScript 2019.3.15

    方法名.call(对象)可以切换方法调用的对象 参数数量 基本数据类型 typeof无法更细致的区分引用类型(全是object) =

  5. 编写注册表.reg文件

    Windows 中的注册表文件( system.dat 和 user.dat )是 Windows 的核心数据库,因此,对 Windows 来说是非常重要的. 通过修改注册表文件中的数据,可以达到优化 ...

  6. PAT Advanced 1064 Complete Binary Search Tree (30) [⼆叉查找树BST]

    题目 A Binary Search Tree (BST) is recursively defined as a binary tree which has the following proper ...

  7. CF round #622 (div2)

    CF Round 622 div2 A.简单模拟 B.数学 题意: 某人A参加一个比赛,共n人参加,有两轮,给定这两轮的名次x,y,总排名记为两轮排名和x+y,此值越小名次越前,并且对于与A同分者而言 ...

  8. 第二季 第四天 part2

    数据类型的转换 转化为字符串 String(value) 转型函数 这个转型函数能把任何类型的值转化为字符串 如果值有toString()方法 则用这个方法(调用没有参数的toString,默认十进制 ...

  9. [CF百场计划]#3 Educational Codeforces Round 82 (Rated for Div. 2)

    A. Erasing Zeroes Description You are given a string \(s\). Each character is either 0 or 1. You wan ...

  10. 3. 现代 javascript 数组专题 和 对象专题

    数组专题 展开运算符 使用...符号, 可以将数组"展开". 数组展开的妙用 ... eg: // 代替apply const foo = [1, 2, 3] const bar ...