输出字符串

方法一:单引号

'http'

方法二:双引号

"http"

方法三:三引号

"""http"""

输出单引号:"let's go"

输出双引号:'she say "yes使用转移符"\"

>>>print('she said "yes! let\'s go"')

>>>print("she said \"yes! let's go\"")

 

 

字符串长度计算len(s):

>>>len("pear")

4

>>>len('pear')

4

>>>len('')

0

>>>len('you are') 空格也算一个字符,不管前中后

7

 

字符串拼接(+),拼接后输出也是字符串:

>>>'hot'+' dog'

'hot dog'

>>>'one '+"two "+'three'

'one two three'

多次拼接(*):

>>>'he'*3 或者3*'hehe'

'hehehe'

>>>len('good'+boy)*'it'

ititititititit

posted @ 2016-07-30 10:03  YunMan  阅读(177)  评论(0)    收藏  举报