人生旅途光阴的故事

三分钟热情自学 Python · 第8期 · Python 字符

2020-08-24  本文已影响0人  游文影月志

宠辱不惊,闲看庭前花开花落;去留无意,漫随天外云卷云舒。
——洪应明

1. 前言

在这个生活中处处都是大数据和人工智能的时代,总是能在各种角落看到 Python 的培训广告。我招架不住敌方的猛烈攻势,败下阵来。经过了一分钟的深思熟虑,我决定利用我的三分钟热情进行回击,从零开始自学 Python

\color{MintCream}{欢迎关注我的公众号:游文影月志}

2. Manipulating Strings | 字符串操作

2.1 Working with Strings | 处理字符串

2.1.1 Double Quotes & Single Quotes | 双引号和单引号

Strings can begin and end with double quotes, just as they do with single quotes. One benefit of using double quotes is that the string can have a single quote character in it.

字符串可以以双引号开头和结尾,就像使用单引号一样。 使用双引号的好处之一就是字符串中可以包含单引号字符。

However, if you need to use both single quotes and double quotes in the string, you'll need to use escape characters.

但是,如果需要在字符串中同时使用单引号和双引号,就需要用到转义符了。

2.1.2 Escape Characters | 转义字符

An escape character lets you use characters that are otherwise impossible to put into a string.

转义字符可以让你在字符串中输入一些使用其他方式不能输入的字符。

Escape Sequence Meaning
\newline Backslash and newline ignored
\\ Backslash (\)
\' Single quote (')
\" Double quote (")
\t ASCII Horizontal Tab (TAB)
\n Newline
上一篇下一篇

猜你喜欢

热点阅读