📜  Python中的多行打印

📅  最后修改于: 2022-05-13 01:55:22.917000             🧑  作者: Mango

Python中的多行打印

之前的文章我们已经看到了打印函数的基本使用。现在,让我们看看如何使用打印函数进行多行打印。这可以使用多行字符串轻松完成,即三个单引号''' Geeksforgeeks '''

让我们看看不同的例子来看看相同的演示。

示例 #1:

# basic example for multi-line printing
print(
'''
=======================================
|                                     |
|                                     |
|          GeeksforGeeks              |
|                                     |
|                                     |
=======================================
'''
    )
输出:
=======================================
|                                     |
|                                     |
|          GeeksforGeeks              |
|                                     |
|                                     |
=======================================

示例 #2:

# basic example2 for multi-line printing
print(
  '''list.head        second              third 
         |                |                  | 
         |                |                  | 
    +----+------+     +----+------+     +----+------+ 
    | 1  | None |     | 2  | None |     |  3 | None | 
    +----+------+     +----+------+     +----+------+ 
    '''
    )
输出:
list.head        second              third 
         |                |                  | 
         |                |                  | 
    +----+------+     +----+------+     +----+------+ 
    | 1  | None |     | 2  | None |     |  3 | None | 
    +----+------+     +----+------+     +----+------+