笨方法学python中的一个小问题,新手求教!!
为什么字符串"But it didn't sing."打印出来的是双引号???谢谢各位大神!!! 回复 1# REntropy
为了方便表示字符串,字符串中含有'的,则用"作为分隔符。含有符号"的,则用'作为分隔符。(总结就是单引号括起来的字符串中的双引号不必转义,双引号括起来的字符串中的单引号不必转义。)
如果两个符号都包含的,则需要使用转义符号进行转义,或者使用三个'''或者"""
'hello world'
"hello world"
"hello'world"
'hello"world'
'hello\'world'
"hello\"world"
"""hello",'world"""
'''hello',"world'''
都是合法的表示方法。 回复 2# lcofjp
终于明白了,非常感谢,希望以后还能请教你!!
页:
[1]