python中”\“的用法

来源:互联网 发布:淘宝直播用什么摄像头 编辑:程序博客网 时间:2024/05/15 08:31

1.作为转义字符对字符串种的引号进行转义:

‘let’\s go!’
“let’s go!”
此处中‘\’即为转义字符

2.换行
print ‘Once upon a time, there was a king’\
‘called Gumby.’
输出结果为:Once upon a time,there was a king name called Gumby.

3.用于不同的字母前表示不同的含义:
如 \n表示换行,\t表示制表,(遇到再及时的更新)
print(“He is a boy, \n but she is a girl”)

结果

He is a boy,

but she is a girl.

0 0