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 || || || || || || || =============================
热门推荐
10 八一幼儿祝福语大全简短
11 公司乔迁食堂祝福语简短
12 婚礼结束聚餐祝福语简短
13 儿媳买车妈妈祝福语简短
14 毕业送礼老师祝福语简短
15 同事辞职正常祝福语简短
16 恭贺新婚文案祝福语简短
17 金店立秋祝福语简短英文
18 婆婆高寿祝福语大全简短