用心纪录,用心发现。

python中'\'的用法

上一篇 / 下一篇  2014-08-06 15:35:15 / 个人分类:Python

1.换行(与Bash效果相同)

' this is the frist sentence.\

this is the second sentence.'

其输出结果为 this is the frist sentence.this is the second sentence.

又print/

    (s)

等同于print(s)

 

2.用于输出 ' \ " 等特殊符号

'What\'s your name?'  =="what's your name?"

\\ == 输出"\"

 

3.用于特殊字母前表示不同的意义

如 \n  代表换行

print("this is the frist line \n this is the second line")

结果

this is the frist line

this is the second line


TAG: Python

 

评分:0

我来说两句

Open Toolbar