\
+
字符符号 | 说明 |
---|---|
\n | 换行,一般用于末尾,strip对其也有效 |
\t | 横向制表符(可以认为是一个间隔符) |
\v | 纵向制表符(会有一个男性符号) |
\a | 响铃 |
\b | 退格符,将光标前移,覆盖(删除前一个) |
\r | 回车 |
\f | 翻页(几乎用不到,会出现一个女性符号) |
\' | 转义字符串中的单引号 |
\'' | 转义字符中的双引号 |
\\ | 转义斜杠 |
r
来将当前字符串的转义字符无效化print(r'hello \f')
r
对格式化
无影响# coding: utf-8
info_n = ('my name \nis %s\n' % 'dewei')
print(info_n)
info_t = 'my name \tis dewei'
print(info_t)
info_v = 'my name \v is dewei'
print(info_v)
info_a = 'my name \a is dewei'
print(info_a)
info_b = 'my name is dewei\b'
print(info_b)
info_r = 'my name is dewei\r'
print(info_r, info_b)
info_f = 'my name is dewei\f'
print('f', info_f)
print('my name is \'dewei\'')
print("my name is \"dewei\"")
print('my name is \"Dewei\"')
print('my name is \\ dewei')
print(r'my name is \\ dewei\n')
print(r'my name is %s' % 'dewei')