列表 list = [item1, item2, ...] 如何定义空列表 1. em_list = list() 2. em_list = [] 如何遍历一个列表 # for循环 for i in alist: print(i) # while循环 i = 0 while i < len(alis ...
分类:
编程语言 时间:
2020-10-16 11:13:11
阅读次数:
23
1.1 列表的局限 前面我们说通过队列的 rpush 和 lpop 可以实现消息队列(队尾进队头出),但是消费者需要不停地调用 lpop 查看 List 中是否有等待处理的消息(比如写一个 while 循环)。 为了减少通信的消耗,可以 sleep()一段时间再消费,但是会有两个问题: 1、如果生产 ...
分类:
其他好文 时间:
2020-10-14 20:38:26
阅读次数:
21
分支语句包括if,switch;循环语句包括while,for,dowhile;if,else语句在书写时要注意格式,else总是与相邻的if语句相匹配;switch语句没办法直接实现分支,只能判断选择,需要break实现分支;switch语句允许嵌套使用;循环语句要注意continue,break的用法;continue是结束本次循环,继续执行下一次循环;break是结束整个循环。
分类:
其他好文 时间:
2020-10-13 17:27:53
阅读次数:
20
常用的三种方式: while read linedoecho $linedone < filename(待读取的文件) cat filename(待读取的文件) | while read linedoecho $linedone for line in `cat filename(待读取的文件)`d ...
分类:
系统相关 时间:
2020-10-12 20:17:26
阅读次数:
25
In our last example, we explored the scheduling of 2 factories. Both factories had 2 costs: Fixed Costs - Costs incurred while the factory is running ...
分类:
其他好文 时间:
2020-10-12 20:02:33
阅读次数:
27
public static void main(String[] args) { int v = 1; int[] a = {1,2,3,4,5}; int left = 0; int right = a.length - 1; while (left <= right) { int mid = ( ...
分类:
编程语言 时间:
2020-10-10 17:46:50
阅读次数:
31
几种循环的区别:until循环,只要特定条件为假,until语句就会执行。while循环只要特定条件为真,”while”语句就会执行for循环”for”循环总是接收“in”语句之后的某种类型的字列表。i++的意思其实就是i+1双小括号:一、echo$((16#5f))结果为95(16进位转十进制)二、重定义变量值,比如a=5;((a++))可将$a重定义为6数值比较参数:等于Isequaltoth
分类:
系统相关 时间:
2020-10-10 17:28:11
阅读次数:
33
LeetCode 142 环形链表II 问题描述: 给定一个链表,返回链表开始入环的第一个节点。 如果链表无环,则返回 null。 为了表示给定链表中的环,我们使用整数 pos 来表示链表尾连接到链表中的位置(索引从 0 开始)。 如果 pos 是 -1,则在该链表中没有环。 快慢指针 快指针每次走 ...
分类:
其他好文 时间:
2020-10-10 17:15:32
阅读次数:
15
// 双指针 var findContinuousSequence = function(target) { let res = [] let left = 1 let right = 2 while (left < right) { let sum = (left + right) * (righ ...
分类:
Web程序 时间:
2020-10-10 17:08:08
阅读次数:
18
地址 https://leetcode-cn.com/problems/linked-list-cycle/ 给定一个链表,判断链表中是否有环。 如果链表中有某个节点,可以通过连续跟踪 next 指针再次到达,则链表中存在环。 为了表示给定链表中的环,我们使用整数 pos 来表示链表尾连接到链表中的 ...
分类:
其他好文 时间:
2020-10-09 21:12:37
阅读次数:
21