1、打开JUPYTER NOTEBOOK,新建一个PY文档。

2、a = 'My name\'s peter'
print(a)
\'可以用在当一个字符串是单引号的前提下,这样PYTHON就不会出错。

3、b = "This is what we call \"good\" things."
print(b)
\"这个情况是因为有双引号,所以方法和上面的一样。

4、b = "This is what we call \"good" things."
print(b)
注意看这里少了一个\,所以就出错了,因为字符串需要一对引号。

5、c = "My name is Peter.\tYour name is Alice."
print(c)
\t可以使得该位置进行Tab,也就是连续4个空格。

6、d = "My name is Peter.\nYour name is Alice."
print(d)
\n是经常会用到的,用于换行。使得字符串看起来更加工整一些。

7、e = "We are using \ in Windows."
print(e)
e = "We are using \\ in Windows."
print(e)
当字符串里面我们需要表示\,那么可以在前面再加一个,形成\\,这样会更加清晰。

8、f = 'I\'m Peter.\nMy name is Peter.'
print(f)
上面说的全部其实都可以用在同一个字符串里面,根据实际情况来运用。
