for _ in list_new:
print(_)
第一种:for循环遍历每一个元素
第二种:使用index索引访问
for index in range(len(list_new)):
print(list_new[index])
注意index索引是从0~n-1的!
本文介绍了Python中遍历列表的两种常见方法:for循环遍历和使用index索引访问。for循环更简洁易读,而index索引访问则直接通过下标操作元素,但需要注意索引从0开始。
for _ in list_new:
print(_)
第一种:for循环遍历每一个元素
第二种:使用index索引访问
for index in range(len(list_new)):
print(list_new[index])
注意index索引是从0~n-1的!
3万+
4536

被折叠的 条评论
为什么被折叠?