Even though my statement said enter a number, in particular, raw input here simply takes in a set of characters and treats it as a string.
即使我的陈述说的是应该输入一个数字,实际上,这里的原始输入会被当做一个字符,的集合来提取并被当做一个字符串来对待。
You notice what it did, it printed out that little, right up here I'd said enter a number and that's what it's printed out, so I can enter a number and it prints it out.
注意这个程序做了些什么,显示出了指定值,然后显示需要输入个数字,然后程序会显示这个数字,我输入一个数字然后程序显示了它。
We own our own phone number, that allows you to input key strokes like you would any system and this is an example of what we call CS50 Voice.
我们都有电话号码,这就让我们可以输入任意的数字,然后这是CS50,Voice的一个例子。
If you give me a number and a string, I'm going to concatenate them together, it's really different operations, but nonetheless, it's what it's going to do.
如果给的输入是一个数字和一个字符串,我将会把它们连接在一起,这实在是不正确的操作,但是无论如何,它就是会去这么做。
If I'm expecting mostly numbers in, I can certainly try and do the coercion.
数字输入,我能够肯定的来做强制转换。
The answer was, find a mathematical expression depending on the number of inputs.
很不错,答案是,找到一个通过输入数字,计算出来的数字表达式。
Whoa. What happened? I said enter a number.
噢,怎么回事!我说过我们要输入一个数字。
But there's an important thing going on here, if I in fact wanted to combine those into a string I should have told the machine to do that, and I can do that, by explicitly saying, take that, which is a number, then add it to that string.
但是这里有个很重要的事情,实际上想要把这些加到一个字符串里面去,我应该告诉计算机去做这个,我应该这么做,通过明确的输入,也就是把这个对象,一个数字,然后把它加到一个字符串里面去。
I think one of the classic ones for strings is called the Rabin-Karp algorithm. And it's simply the same idea that you have a mapping from your import into a set of integers.
我认为字符串哈希,最经典的是Rabin-Karp算法,它只是简单的相同概念,你有一个映射关系将你的输入映射成一组数字。
I didn't. I gave it a string.
我并没输入数字,我输入了一个字符串。
应用推荐