标签:
方法一:单引号
‘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
标签:
原文地址:http://www.cnblogs.com/yunman/p/5720338.html