如何格式化列表以在 python 的单独行上打印每个元素?

2022-01-15 00:00:00 python list line format

问题描述

如何格式化列表以在单独的行上打印每个元素?例如我有:

How can I format a list to print each element on a separate line? For example I have:

mylist = ['10', '12', '14']

我希望格式化列表,使其打印如下:

and I wish to format the list so it prints like this:

10
12
14

所以 、方括号、逗号和 '' 被删除,每个元素都打印在单独的行上谢谢

so the , brackets, commas and '' is removed and each element is printed on a separate line Thanks


解决方案

你可以只使用一个简单的循环:-

You can just use a simple loop: -

>>> mylist = ['10', '12', '14']
>>> for elem in mylist:
        print elem 

10
12
14

相关文章