如何在迭代前插入额外元素而不影响现有打印元素之间的距离
How to insert extra element before an iteration without affecting the distance between existing printed elements
输入:
a = ['x', 'y', 'z']
语法:
for i in a:
print(f'{i:<14}', end = '')
当前输出:
x y z
预期输出
Title x y z
循环前打印"Title"
:
print("Title", end=' ' * 25)
for i in a:
print(f'{i:<14}', end = '')
输出:
Title x y z
输入:
a = ['x', 'y', 'z']
语法:
for i in a:
print(f'{i:<14}', end = '')
当前输出:
x y z
预期输出
Title x y z
循环前打印"Title"
:
print("Title", end=' ' * 25)
for i in a:
print(f'{i:<14}', end = '')
输出:
Title x y z