问题1)。如果字符串以单引号开始,以三引号结束,它是如何有效的?你知道吗
问题2)。如果第二个打印语句有效,为什么第三个和第四个打印语句无效?你知道吗
print('This is "python" programming') #valid
print('This is "python" programming''') #valid
print(''This is "python" programming''') #Invalid
print('''This is "python" programming') #Invalid
在python中可以concatenate strings by putting them one next to other。你知道吗
例如:
"a" "b"
,甚至在多行上:所以
'This is "python" programming'''
是'This is "python" programming'
和''
的串联。你知道吗三重引号(
'''
或"""
)是另一种在多行上具有字符串跨度的引号。你知道吗来自python手册:
第三个示例实际上是无效的,因为它是一个空字符串,后跟对python没有意义的标识符。你知道吗
最后一个示例无效,因为它以三重引号开始,但不关闭三重引号。你知道吗
相关问题 更多 >
编程相关推荐