- 博客(3)
- 资源 (5)
- 收藏
- 关注
原创 遍历列表时跳过了某些元素
在运行时有两个元素被跳过了。通过查找发现是因为remove删除元素后,整个列表的元素会往前移动,指针是不断增大的。for循环实际是循环的列表下标(索引),同时由于列表的可变性,每一次删除一个元素,列表的长度就会发生变化,元素的索引也会发生变化(List的Remove方法在删除元素的时候总会保持下标连续。在练习函数时,编写程序将animals列表里的元素移动到ana里,并将animals数组清空。
2024-01-10 17:34:30 322 1
原创 python学习2:将一个列表内字符串全部小写赋给新的列表
将current_users的小写赋给users列表,且current_users的大小写不会被更改。print(user,‘已被使用’)print(user,‘未被使用’)
2024-01-08 15:59:29 325 1
原创 Python学习日记(1):
这里写自定义目录标题我们知道,新闻记者和电视工作者Journalists and TV people, we know, are supposed to record what goes on; but in trying to get the best record they can, they may sometimes seem amazingly cold blooded. Some of the seediest of journalists, whether we’re talking ab
2022-05-27 23:24:13 218
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人