Open hug2wisdom opened 4 years ago
效果如图 note that the initial newline is not included
输出:
在:
后传入一个整数, 可以保证该域至少有这么多的宽度。 用于美化表格时很有用。
>>> table = {'Google': 1, 'Runoob': 2, 'Taobao': 3}
>>> for name, number in table.items():
... print('{0:10} ==> {1:10d}'.format(name, number))
...
Google ==> 1
Runoob ==> 2
Taobao ==> 3
当需要多段打印的时候,我们可以使用,
"""......"""
或者是'''.....'''
,因为print
默认会在输出的结果前添加一个新的 line ,所以我们可以用\
,取消掉这个默认的 line。eg:
the result:
注意此时没有
print
带来的默认的 new line.