发布网友 发布时间:2022-04-23 08:05
共2个回答
热心网友 时间:2022-04-06 15:26
list1=['你haodajerect',232,2323.434,32323,2332,23,23234,'ssdfsdf']
list2=['你',2,32,23.3434,3.2434323,2332,23,'s','ssdfsdf']
print("左对齐————————————————————")
for item1 in list1:
print(str(item1).ljust(15,'*'),end=' ')
print('\r\n')
for item2 in list2:
print(str(item2).ljust(15), end=' ')
print('\r\n右对齐————————————————————')
for item1 in list1:
print(str(item1).rjust(15,'*'),end=' ')
print('\r\n')
for item2 in list2:
print(str(item2).rjust(15), end=' ')
print('\r\n居中对齐————————————————————')
for item1 in list1:
print(str(item1).center(15,'*'),end=' ')
print('\r\n')
for item2 in list2:
print(str(item2).center(15,"*"), end=' ')
Python中print输入打印左对齐,右对齐,居中对齐等
热心网友 时间:2022-04-06 16:44
用格式化输出。