#遍历字典, 分别打印key, value, key:value emp = {'name':'Tom', 'age':20, 'salary' : 8800.00} for k in emp.keys(): print('key = {}'.format(k)) for v in emp.values(): print('values = {}'.format(v)) for v,k in emp.items(): print('{v}:{k}'.format(v = v, k = k)) 打
// Playground - noun: a place where people can play import UIKit //------------------------------------------------------------------------------ // 1. for // 传统的for循环方式在swift中同样支持 var num = 0 for(var i = 0; i < 10 ; i++) { num += i } num //---------
// Playground - noun: a place where people can play import UIKit //------------------------------------------------------------------------------ // 1. for // 传统的for循环方式在swift中相同支持 var num = 0 for(var i = 0; i < 10 ; i++) { num += i } num //---------
zhuazai:https://blog.csdn.net/sty945/article/details/79830915 前言 ls命令 ls -a ls -l ll du命令 du -s du -s * du -s * | sort -nr 我的DIY_Bash 在linux任意位置都可以使用这个目录下的脚本 注意 前言 最近几乎大部分工作都在linux上进行的,发现在工作过程中经常要查看当前目录下的文件大小,但是每次都是用ls命令每次都是以字节形式显示的,看起来特别不爽.于是开始了再lin
在遍历list,删除符合条件的数据时,总是报异常,代码如下: num_list = [1, 2, 3, 4, 5] print(num_list) for i in range(len(num_list)): if num_list[i] == 2: num_list.pop(i) else: print(num_list[i]) print(num_list) 会报异常:IndexError: list index out of range 原因是在删除list中的元素后,list的实际长度变
ArrayList与LinkedList的普通for循环遍历 对于大部分Java程序员朋友们来说,可能平时使用得最多的List就是ArrayList,对于ArrayList的遍历,一般用如下写法: public static void main(String[] args) { List<Integer> arrayList = new ArrayList<Integer>(); for (int i = 0; i < 100; i++) { arrayList.add(i)