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

    Python数据分析(中英对照)·Lists 列表

    列表是任何类型的对象的可变序列。 Lists are mutable sequences of objects of any type. 它们通常用于存储同质项目。 And they’re typically used to store homogeneous items. 列表是序列的一种类型,就像字符串一样,但它们确实有区别。 Lists are one type of sequence, just like strings but they do have their differences. 如果我们比较字符串和列表,一个区别是字符串是单个字符的序列, If we compare a string and a list, one difference is that strings are sequences of individual characters, 而列表是任何类型Python对象的序列。 whereas lists are sequences of any type of Python objects. 字符串和列表之间的另一个区别是字符串是不可变的,而列表是可变的。 Another difference between strings and lists is that strings are immutable, whereas lists are mutable. 除了这两个区别之外,字符串和列表当然也有自己的方法。 In addition to these two differences, strings and lists, of course,come with their own methods. 通常情况下,列表只包含一种类型的对象,尽管这不是严格的要求。 It is common practice for a list to hold objects of just one type,although this is not strictly a requirement. 让我们尝试几个简单的列表来测试它们。 Let’s try a couple of simple lists to experiment with them. 让我们构造一个简单的数字列表,以进一步了解列表。 Let’s construct a simple list of numbers to learn a little bit more about lists. 所以我要构造一个数字列表。 So I’m going to construct a list of numbers. 我要称之为数字。 I’m going to call it numbers. 我将使用数字2、4、6和8。 And I’ll use numbers 2, 4, 6, and 8. 假设我想提取或访问列表中的第一个元素。 Imagine I wanted to extract, or access, the first element of my list. 我要做的第一件事是键入列表的名称,然后我需要方括号。 The first thing for me to do is type the name of the list,then I need my square brackets. 现在请记住,在Python中,索引从零开始。 Now remember, in Python, indexes start at zero. 因此,为了能够查看该列表的第一个元素,我需要将其放入索引0,位置0。 So for me to be able to look at the first element of that list,I need to put in index 0, position 0. 在这里,Python告诉我第一个对象,即位于位置0的对象,是数字2。 Here, Python tells me that the first object, meaning the object located at position 0, is number 2. 如果我将索引更改为1,Python将给我第二个对象。 If I change the index to 1, Python gives me the second object. 现在,如果我想知道列表上最后一个对象是什么,我可以从右到左计算位置。 Now if I wanted to find out what is the very last object on my list,I can count positions from right to left. 这意味着我必须使用负指数。 And

    02

    抖音短视频系统开发,消息机制的原理细节处理

    对于Android抖音短视频系统开发来说,Binder和Handler是两大利剑,分别实现了进程间和线程间的通讯。Android的消息机制,主要包括Hander,Looper,Message和MessageQueue四个数据类型,但从概念上讲,核心是线程和消息队列,一切操作围绕某个线程和它对应的消息队列展开,抖音短视频系统开发常用Handler,Looper,MessageQueue这三个类都会和同一个线程绑定。主要原理为通过Threadlocal让每个线程具备了一个消息队列,消息队列一方面作为存储消息的数据结构,另一方面负责消息具体的入列,出列,阻塞等核心操作;而Handler负责将消息发送到相应线程的消息队列中,并对出列的消息进行处理;而Looper则通过循环,不断的尝试获取消息并对获取到的消息进行分发,交给消息对应的target(Handler)来处理,然后在消息处理完毕后进行回收,回收到消息池中。

    05

    操作系统实验多线程编程中的读者优先和写者优先

    首先需要理解在线程无论是读者优先还是写者优先都需要尊重两种约束,就是读写与写写操作是无法同时进行的,能同时进行就只能是读读操作 其次需要理解读者优先于写者优先的概念 首先说的是读者优先 许多人对读者优先的概念可能就直接是读者的优先权最大,这样的想法是错误的,假设已经在进行一个写线程了,那么这时候来的读线程是无法让写线程退出,在执行读线程的。 只存在这说有一个读线程在执行,这时候又来了一个读线程,这时候后来的那个读线程是能够并发的执行的,但假设在这个读线程之后又来了一个写线程, 这时候的写线程需要等到所

    02
    领券