在Python中,可以使用print()函数来输出列表。以下是一些技巧:
my_list = [1, 2, 3, 4, 5]
print(*my_list)
my_list = [1, 2, 3, 4, 5]
print(*my_list, sep=', ')
my_list = [1, 2, 3, 4, 5]
for num in my_list:
print(num, end=' ')
my_list = [1, 2, 3, 4, 5]
for index, value in enumerate(my_list):
print(f'Index: {index}, Value: {value}')
my_list = [1, 2, 3, 4, 5]
print(' '.join(map(str, my_list)))