So, when in doubt, if you're having some weird character issue, odds are you need to escape it in some way.
如果你有拿不准的字符,可能就要用到转义字符了。
The Japanese was hard when I learned the characters,
我学字符的时候觉得日语很难,
f truth is the recognition of the systematic character of a certain kind of error, then it would be fully dependent on the prior existence of this error.
如果真理是,对一种错误的系统化字符的认可,那么它会完全依赖于这个错误的先前存在。
C So here I'm declaring a variable called c, and I'm pretty much translating the formula from the slide using the characters on my keyboard to a floating point value.
这里我声明了一个变量,然后我把那个幻灯片上的公式,用键盘上的字符翻译成了,浮点数值。
So now here's the idea. I build a list 256 elements long, and I fill it up with those special characters none.
所以这里就是这种思想6,我创建了一个可以放下256个元素的列表,然后我以这些没有实际意义的字符将其填充。
It's not just 140 characters, it's potentially $140 because they can't make the sale.
这并不只是140个字符的问题,它只是潜在的140美元,因为这些字不能卖出去。
The Greeks borrow that with typical Greek innovation.
希腊人用他们典型的创新手段,借用了这些字符
Usually with just two, maybe three characters, a character that you can't really see as well on the screen, otherwise, so a new line character.
通常需要两到三个字符,这些字符你们在屏幕上是,看不到的,这个是换行字符。
You don't see strings with commas between them, but it has the same kind of property. It is in ordered sequence of characters.
它是有序的字符序列,我们可以对字符串做同样的操作,我们也可以得到字符串中的一块。
FOR c It's going to say FOR c, which was my name for the character in that string.
那么循环要去做什么呢?循环要去说,也就是字符串中字符的名字。
If I want a copy of the string, I've got to whip out my week 1 skills of just iterating with a four loop from left to right and make copies of those characters.
我需要那个字符串的一个拷贝,我使用,第一周的技巧,从左到右做四次迭代,然后复制这4个字符。
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.
即使我的陈述说的是应该输入一个数字,实际上,这里的原始输入会被当做一个字符,的集合来提取并被当做一个字符串来对待。
If you want to escape certain characters, you need to use these so-called escape sequences.
如果你想与其他字符隔开,你就要用到所谓的转义字符。
That's pretty good 'cause now, I can pretty much cover my American keyboard pretty effectively both upper case, lower case, and a whole bunch of punctuation. For other languages as in aside, there are other encoding schemes when there are more characters.
那是相当不错的,它可以包含整个美式键盘中的字符,包括大小写字母和一连串标点,对于其他语言,当涉及更多字符时就会有其他的编码体系。
I print out -- and this is only wrapping - because of the big font -- I print out, "I demand that you give me a positive integer."
我打印出来--这个字符相互覆盖了,因为用的是大字体-,我打印:“我需要你给我一个正整数“
So with eight bits can you express 256 possible characters?
用八个比特你就可以表达256个可能的字符?
But a char we've seen, a character being a single character.
正如我们看到的,一个字符就是一个单独的字符。
In the case of integers it was easy.
情况非常简单,在字符的例子中。
Well it turns out a bunch of years ago people just decided that if we have the ability to express numbers and we actually care about expressing letters of the alphabet, well we just need some kind of mapping between one and the other, ASCII and so thus was born what's generally called the ASCII.
结果证实,数年前,人们觉得如果我们,有数字表达能力,而我们真正在乎其实是字符的表达,那么我们就需要数字和字符的某种对应关系,于是就有了俗称的。
I give it some character. It gives me back an integer representing. It looks weird.
我输入一些字符,程序返回给我一个整数的表示。
Now for the hacker edition, if you are feeling up to a bit more of a challenge you'll find that when you run the game, one it's not all that hard to use some ASCII art just make it a little fancier as the teaching fellow who implemented this solution did.
对于升级版,如果你能应付更大的,挑战,你会发现当你在玩这个游戏时,用一些字符画把它做得,比那些教学人员做的更有新意,并不是那么困难。
But this is perhaps a very simple example of ASCII art.
这是字符艺术方面一个非常简单的例子。
So this part is the cookie cutter stuff.
所以这是个可以插入字符的括号。
And even though the syntax, the characters you are about to see on the screen and in programs today onward is a little more arcane, it's a little uglier looking, you've got semicolons and parentheses and fairly arcane syntax, realize that at the end of the day these are just arbitrary human conventions, the ideas are identical to this thing here.
可能你在屏幕上,编程中见识到的,语法,字符看起来非常晦涩难懂,甚至可以说是丑陋,像什么分号啊,括号啊等等,还有一些难七八糟的语法,但是到了最后,你会发现,这些都不过是一些人为约定而已,而蕴含在里面的编程思想跟这个例子并无二致。
But there're others, backslash T. Folks in the consulting world and finance world like to share files in Excel format or in Text format that looks like Excel.
还有一些其他的转义字符,譬如\t,顾问界,财政界的,人们很喜欢用Excel文档,或类似于Excel的文本文件。
5 So similarly would there be the number 65 next to this then the corresponding number for V-I-D and then there's generally a special character at the end that looks like a zero that says end of string here.
同样,A就是,接着再填上V-I-D对应的ASCII码,在最后还有添上一个特殊的字符,有点像0,代表这是该字符串结束。
I'm going to delete that arrow and actually draw s2 as pointing to this chunk of memory because whereas before this sequence of chars might have lived at address 71 or whatever, well, this one might live at 91.
我不会把那个箭头删除,实际上我画了s2作为,这块内存的指针,因为,这个字符序列存储在地址71或其它的地方,这个可能存储在91的地方。
Well it's a stupid looking program, but because I had more new line characters, and because I was using percent C, for individual characters, one per line, now I'm seeing dot slash ARG V2, well, now if I go ahead and rerun this with foo, I get this effect as well.
这是一个看起来很笨的程序,但是因为我有更多的新行代码,因为我使用的是%c,为单个字符使用的,每一行一个,现在我看到的是,/argv2,好的,现在如果我继续用foo返回它,我产生了这样的效果。
If they type in bogus characters, it's going to yell at them and make them retry, and eventually I'm going to get handed back an int, which I'm storing in n. Well, if I actually want to judge this number based on its magnitude, well, I can say now, "If n is greater than or equal to one."
如果他们键入了不合法的字符,它将对他们叫喊,然后叫他们重试,最终我将,得到一个int数,它是存储在n中的,好的,如果我的确想要根据它的量级来判定这个数字,好的,现在我可以指明,“是否n大于等于1“
I certainly don't want to assume they're always going to type a three-letter or a four-letter or a two-letter word I want some dynamism but that's fine because get string can get a string of any length, I can then use the string length function to just ask while the program is running how big is the string that I was handed?
当然我不能假设他总是,输入3个字符或4个字符,或2个字符的单词,我想要动态地分配,因为GetString可以获得任意长度的字符串,然后我可以使用strlen函数,来得到那个我传递的字符串,有多长?
应用推荐