第179页 | Learning Python | 阅读 ‧ 电子书库

同步阅读进度,多语言翻译,过滤屏幕蓝光,评论分享,更多完整功能,更好读书体验,试试 阅读 ‧ 电子书库

String Literals

By and large, strings are fairly easy to use in Python. Perhaps the most complicated thing about them is that there are so many ways to write them in your code:

 

 
Single quotes: 'spa"m'Double quotes: "spa'm"Triple quotes: '''... spam ...''', """... spam ..."""Escape sequences: "s\tp\na\0m"Raw strings: r"C:\new\test.spm"Byte strings in 3.0 (see Chapter 36): b'sp\x01am'Unicode strings in 2.6 only (see Chapter 36): u'eggs\u0020spam'

The single- and double-quoted forms are by far the most common; the others serve specialized roles, and we’re postponing discussion of the last two advanced forms until Chapter 36. Let’s take a quick look at all the other options in turn.

请支持我们,让我们可以支付服务器费用。
使用微信支付打赏


上一页 · 目录下一页


下载 · 书页 · 阅读 ‧ 电子书库