python中转义是什么意思_python中的转义

当需要在字符串中使用特殊字符时,我们需要用到python中的反斜杠()转义字符。下面介绍几个餐饮的转义符:

\:反斜杠符号

print('2.Amy got up late, and she said "I miss the breakfast,this monring"')#\\是单斜杠

输出结果如下:

36770274105a

image.png

\':单引号

print('4.Amy got up late, and she said \'I miss the breakfast,this monring\'')#\\是单引号

输出结果如下:

36770274105a

image.png

\":双引号

print("3.Amy got up late, and she said \"I miss the breakfast,this monring\"")#\"是双引号

输出结果如下:

36770274105a

image.png

\a:响铃

print('5.Amy got up late, \aand she said "I miss the breakfast,this monring"')#\a是响铃符

输出结果如下(会有响铃声):

36770274105a

image.png

\b:退格(Backspace)

print('6.Amy got up late, \band she said "I miss the breakfast,this monring"')#\b是退格符

输出结果如下:

36770274105a

image.png

\n:换行

print('8.Amy got up late, \nand she said "I miss the breakfast,this monring"')#\n是换行符

输出结果如下:

36770274105a

\v:纵向制表符

print('10.Amy got up late, \vand she said "I miss the breakfast,this monring"')#\v是垂直制表符

输出结果如下:

36770274105a

image.png

\t:横向制表符

print('\t1.Amy got up late, and she said "I miss the breakfast,this monring"')#\t是tab

输出结果如下:

36770274105a

image.png

\r:回车

print('9.Amy got up late, \rand she said "I miss the breakfast,this monring"')#\r是回车

输出结果如下:

36770274105a

image.png

\f:换页

print('7.Amy got up late, \fand she said "I miss the breakfast,this monring"')#\f是换页

输出结果如下:

36770274105a

image.png

\xyy:十六进制数,yy代表的字符,例如:\x0a代表换行

\other:其它的字符以普通格式输出

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值