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.
即使我的陈述说的是应该输入一个数字,实际上,这里的原始输入会被当做一个字符,的集合来提取并被当做一个字符串来对待。
So STR, which I just typed up there, takes in parens, some input, and it converts it into a string, so that now I can use that John where I was expecting a string. John.
因此STR,也就是,我刚刚输入的,然后把这个输入变更为一个字符串,因此现在我就能,在需要用字符串的地方使用这个对象了。
I'm going to use the CS50 Library instead for user input I'm saying say something then I'd get a string from the user and I call time s1 and then I say, say something, s2 and then I get another string from the user and call it s2 and apparently this program's purpose in life is to tell me yes or no the user said the same thing both times.
然而我使用的是CS50库来获得用户输入,我说点什么,然后从用户那里获得一个字符串,并把它叫做s1,然后我说点什么,然后从用户那里获得一个字符串,并把它叫做2,这个程序的最终目的是,告诉我两次用户输入的是不是同样的东西。
b OK. In this example I'd use b. All right, as b get-- b is the thing that's changing as I go along here, but it could be things like, how many elements are there in a list if the input is a list, could be how many digits are there in a string if the input's a string, it could be the size of the integer as we go along. All right.?
好,在这个例子里我会用,因为b是一直在变的东西,但是也可能是如下情况:,如果输入是数组的话,变化的就是数组的元素数,如果输入是字符串的话,变化的就是字符串的长度,如果是integer的话,可能就是这个数的大小,对不对?
应用推荐