Python习题册013:打印指定文字

任务011描述

用Python编写一个程序,打印与下文一模一样的文字。
示例文字如下:
a string that you "don't" have to escape
This
is a ....... multi-line
heredoc string --------> example

分析及示例

这个字符串中涉及单引号、双引号,还涉及多行。因此不能单引号或双引号直接来表示——当然可以用置换符来代替其中的特殊字符,例如用\'\n等,但更简单的方式是使用三单引号或三双引号的方式。

示例代码如下:

tempStr='''
a string that you "don't" have to escape
This
is a  ....... multi-line
heredoc string --------> example
'''
print(tempStr)

输出结果:

a string that you "don't" have to escape
This
is a  ....... multi-line
heredoc string --------> example

猜你喜欢

转载自blog.csdn.net/weixin_33924220/article/details/87753939