My answer is, you can't change one but you can create a new one that is almost like the old one but different in a little bit.
既然你不能改变元组,你可以新建一个跟原来的元组,大体上一致但有细微差别的元组。
And the nice thing is that there's a shared behavior there. Just as I can have tuples as an ordered collection of things, strings behave as an ordered collection of things.
共享的行为,就像元组是有序的元素序列,字符串也是有序的元素序列,因此我可以对字符串做同样的操作,我可以把它们连结起来。
This is a kind of meta-literary allegorization that I'll be performing here: you could also think of Milton the poet as being stuck at this same juncture.
这是一种元文学的语词新作,我现在会开始展示,你们也可以思考一下,诗人弥尔顿也在同样的时刻陷入僵局。
You build a steel plant with a capital cost of several billion dollars.
你可以建立一个钢铁的地球,只要几十亿元的投入。
In fact it gives me back, now I hate this, it's actually a list it's not a tuple. But for now think of it as giving you back an explicit version of that representation of all those elements.
它实际上是一个数组而不是一个元组,但是现在你们可以把它认为,是明确的这些,元素的一个表示,你会在接下来的一些课程中看到。
All right. What does this have to do with my divisor example? This says I can make tuples, but imagine now going back to my divisor example and I want to gather up the elements as I go along. I ought to be able to do that by in fact just adding the pieces in.
这意味着我可以创建元组了,但是想像下回到我们的除数的例子,在处理过程中我们想把目标数的除数,收集起来,我应该能够通过把这些数,一个一个加进来来实现这个目的,我正是要去这么做,也就是。
I'm going to give a name to that. And what you see there is I'm going to call divisors initially an empty tuple, something has nothing in it. Right here. And then I'm going to run through the same loop as before, going through this set of things, doing the check.
你们可以看到这里,我初始化一个空的元组,名为divisiors,这里,然后我会去运行,跟以前一样的循环,遍历这个集合内的东西,然后做检查,现在我要做的是,每次我找到了一个除数我要把它收集起来。
应用推荐