各种转义字符\\\\\\

今日阅读:【17个新手常见Python运行时错误】http://www.dedecms.com/knowledge/program/other/2012/0731/4046.html

今日学习:

Exercise 9: Printing, Printing, PrintingExercise 10: What Was That?

1. \n 输出的是换行

2.输出string时要注意引号的

3.如果要用%r,%s输出string,不用用逗号隔开。

eg: days=‘MondayTuesday Wedesday Thuseday Friday Saturday Sunday’

print”Here are the days:%r” %days

4.如果输出string有用到换行\n关键字,用%s输出有换行效果,但如果用%r,则是直接输出\n字符,无换行效果。

5.输出的“”“。。”“” 三引号的用法要注意一下。用三引号输出的话,就是里面的string语句可以有很多句。可以自定格式。

6.【\的使用】输出的string中如果有会引起系统误会的字符,则在此符号前使用\,那么它就会按原样输出了。(这个在C里好像叫转义符号)

7.【Escape Sequences】

This is the list of all of the escape sequences Python supports. You may not use many of these, but memorize their format and what they do anyway. Also try them out in some strings to see if you can make them work.

Escape What it does. \\Backslash ()\'Single quote (‘)"Double quote (“)\aASCII Bell (BEL)\bASCII Backspace (BS)\fASCII Formfeed (FF)\nASCII Linefeed (LF)\N{name}Character named name in the Unicode database (Unicode only)\rASCIICarriage Return (CR)\tASCIIHorizontal Tab (TAB)\uxxxxCharacter with 16-bit hex value xxxx (Unicode only)\UxxxxxxxxCharacter with 32-bit hex value xxxxxxxx (Unicode only)\vASCII Vertical Tab (VT)\oooCharacter with octal value ooo\xhhCharacter with hex value hh

————————————————————————————————————————————————————–

【Most programming errors in the beginning (and even later) are simple spelling mistakes, typos, or getting simple things out of order.】

【Periodicallygo through your notes and see if you can figure these things out after you’ve completed more exercises. Sometimes though you may need to go back a few exercises and go through them again.】

【Always remember this:%ris for debugging,%sis for displaying.】

如果我们想要更多的玫瑰花,就必须种植更多的玫瑰树。

各种转义字符\\\\\\

相关文章:

你感兴趣的文章:

标签云: