Python多行打印
我们通常在python中看到print命令打印一行输出。但是,如果要打印多行,则采用这种方法需要编写多个打印命令。可以通过使用另一种涉及三个单引号的技术来避免这种情况,如下所示。
示例
print('''
Motivational Quote :\n
Sometimes later becomes never, Do it now.
Great things never come from comfort zones.
The harder you work for something, the greater you'll feel when you achieve it.
''')运行上面的代码将为我们提供以下结果:
Motivational Quote : Sometimes later becomes never, Do it now. Great things never come from comfort zones. The harder you work for something, the greater you'll feel when you achieve it.
我们可以使用多行打印来生成格式正确的文本,如下所示。
示例
print('''
===========================================
|| ||
|| WORK ||
|| HARD ||
|| ||
|| ||
|| ||
===========================================
''')运行上面的代码将为我们提供以下结果:
============================= || || || WORK || || HARD || || || || || || || =============================
热门推荐
3 祝福语简短的微信
10 幼儿祝福语大全简短贺卡
11 感谢教官文案祝福语简短
12 鼠年同事祝福语简短创意
13 元旦祝福语 简短独特群发
14 妈咪跟我生日祝福语简短
15 给儿子新婚祝福语简短
16 伴娘祝福语长文案简短
17 恭喜高考完祝福语简短
18 生日祝福语送老公简短