python 3.5 之 单双三引号

1. 单引号和双引号用法都是一样的,但是如果字符串里有相同的字符时要使用\进行转义

举例:
1) print 'hello'
2) print "hello"
1和2,结果都是hello

3) print 'hell\'o'
4) print "hell'o"
3和4,结果都是hell'o

5) print 'hell"o'
6) print "hell\"o"
5和6,结果都是hell"o

2. 三引号与他们不同之处:“所见即所得”,对于一段html或xml格式的字符串时用三引号更直观点(此时要用单引号或双引号时候需要进行转义)
如:
print '''
hello'
world"
'''
结果是
hello'
world"
posted @ 2016-08-02 16:38  JokerJason  阅读(543)  评论(0编辑  收藏  举报

It's not who you are underneath, it's what you do that defines you

Brick walls are there for a reason :they let us prove how badly we want things