首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往
您找到你想要的搜索结果了吗?
是的
没有找到

Python数据分析(中英对照)·Ranges 范围

范围是不可变的整数序列,通常用于for循环。 Ranges are immutable sequences of integers,and they are commonly used in for loops. 要创建一个范围对象,我们键入“range”,然后输入范围的停止值。 To create a range object, we type "range" and then we put in the stopping value of the range. 现在,我们刚刚创建了一个范围对象,但是如果您想查看该对象的实际内容,那么这就没有多大帮助了。 Now, we’ve just created a range object, but this is less helpful if you would like to see what’s the actual content of that object. 虽然,我们通常不会在Python程序中这样做,但为了真正看到该范围对象的内容,我们可以在这种情况下将其转换为列表。 Although, we wouldn’t typically do this in a Python program,for us to really see the content of that range object,so what we can do in this case is we can turn it into a list. 所以如果我们说“范围5列表”,我们会看到范围对象由五个数字组成,从0到4。 So if we say "list of range 5," we’ll see that the range object consists of five numbers, from 0 to 4. 范围的输入参数是停止值。 The input argument to range is the stopping value. 记住,Python在到达停止值之前停止。 And remember, Python stops before it hits the stopping value. 这就是为什么范围5实际上不包含数字5。 That’s why range 5 does actually not contain the number 5. 我们可以为range函数提供额外的参数。 We can provide additional arguments to the range function. 例如,我们可以提供起点,也可以定义步长。 For example, we can provide the starting point,and we can also define the step size. 所以如果我们输入“range1到6”,在这种情况下,我们得到一个range对象,它从1开始,到5结束。 So if we type "range 1 to 6," in that case,we get a range object which starts at 1 and ends at 5. 如果我们想以2为增量,我们可以这样做。 If we wanted to go in increments of two, we could do something like this. 我们可以从1开始,一直到13——13号,不包括它本身——我们可以分两步走。 We could start from 1, go up to 13– number 13,not itself included– and we could go in steps of two. 在本例中,我们得到一个从1开始到11结束的范围对象。 In this case, we get a range object that starts at 1 and ends at 11. 通常,当我们在Python程序中使用范围对象时,我们不会首先将它们转换为列表。 Typically when we use range objects in our Python programs,we do not first turn them into lists. 我们在这里这样做只是为了让我们更容易理解这些对象的作用。 We’ve done it here only so that it’s easier for us to understand what these objects do. 当然,您可以在for循环上下文中使用list对象,但由于以下原因,它是有问题的。 You can certainly use a list object in a

04

算法与数据结构(十三) 冒泡排序、插入排序、希尔排序、选择排序(Swift3.0版)

本篇博客中的代码实现依然采用Swift3.0来实现。在前几篇博客连续的介绍了关于查找的相关内容, 大约包括线性数据结构的顺序查找、折半查找、插值查找、Fibonacci查找,还包括数结构的二叉排序树以及平衡二叉树的构建与查找,然后还聊了哈希表的构建与查找。接下来的几篇博客中我们就集中的聊一下常见的集中排序方式,并并给出相应的时间复杂度。本篇博客我们将会详细的介绍冒泡排序、插入排序、希尔排序以及选择排序,下篇博客将继续介绍堆排序、归并排序以及快速排序的相关内容。当然上述内容的代码实现我们依然采用Swift面向

07

Redis从青铜到王者,从环境搭建到熟练使用,看这一篇就够了,超全整理详细解析,赶紧收藏吧!!!

一、常见的非关系型数据库NOSQL分类 二、了解Redis 三、Redis的单节点安装教程 四、Redis的常用命令 1、Help帮助命令 2、SET命令 3、过期命令 4、查找键命令 5、操作键命令 6、GET命令 7、步长命令 8、登录不同的库命令 9、清除当前库数据命令 10、清除所有库中的数据命令 五、BITMAP位图 1、位图常用命令 2、位操作命令 3、统计指定位区间上值为1的个数 六、Redis的数据模型 1、Redis的 key 键 2、Redis的 Value 值 1、String字符串 2、 List列表 3、 Hash散列 4、Set集合 5、SortedSet有序集合 七、Redis持久化 1、Redis持久化-RDB (1)RDB使用策略 (2)SAVE命令 (3)BGSAVE命令 (4)SAVE 和 BGSAVE 命令的区别 (5)RDB持久化的优缺点 2、Redis持久化-AOF (1)AOF写入机制 (2) 写入磁盘的策略 (3)AOF重写机制 (4)AOF重写触发 (5)AOF持久化的优缺点 八、idea使用Jedis连接Redis

02
领券