您好,欢迎来到二三娱乐。
搜索
您的当前位置:首页Python习题册013:打印指定文字

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

Copyright © 2019- yule263.com 版权所有 湘ICP备2023023988号-1

违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务