在Python中,可以使用print()
函數(shù)輸出列表。有兩種方法可以實(shí)現(xiàn):
方法一:直接輸出列表
lst = ['apple', 'banana', 'cherry']
print(lst)
方法二:使用循環(huán)遍歷列表并輸出每個(gè)元素
lst = ['apple', 'banana', 'cherry']
for item in lst:
print(item)
無(wú)論使用哪種方法,輸出結(jié)果都是:
['apple', 'banana', 'cherry']