'\"To be, or not to be\": that is the question.\nWhether it\'s nobler in the mind to suffer.'
print(r'''"To be, or not to be"''': that is the question.\n r'''Whether it\'s nobler in the mind to suffer.''') 怎么换行啊,谢谢
cmd命令行怎么在'''...'''里面换行写后半段的。。
用了r'''...''' 换行直接 敲键盘 Enter 键 就可以了。 不用\n 转义符了。有图有真相
所以。。怎么换行呢??
print(r''''To be,or not to be':that is the question.
Whether it's nobler in the mind to suffer.''')
print('\"To be, or not to be\": that is the question.\n'r'''Whether it\'s nobler in the mind to suffer.''')
这样他就会在\n后面变成换行了。
print(r'''To be, or not to be: that is the question. Whether it's nobler in the mind to suffer.''')
小伙子,代码这样子写哦,注意换行哦
还有,如果一个字符串包含很多需要转义的字符,对每一个字符都进行转义会很麻烦。为了避免这种情况,我们可以在字符串前面加个前缀r
,表示这是一个 raw 字符串,里面的字符就不需要转义了。