参考代码1: 自己模拟出数据,并分别对dataGridView赋值. using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Collections; names
li = [1,2,3,4,5,6] for i in li: if i<3: li.remove(i) print(li) #输出的结果是 [2,3,4,5,6] 2没有remove掉 是因为#在第一次循环的时候,1 被remove掉了#然后坑位由6个变为5个#以后的一次往前排,2到了第一个坑位#然后在迭代的时候,就是从第二个坑位开始迭代,就是从3开始#所以2 就这么被忽略了! 解决: 例子一: 我是在做飞机大战,子弹越界要删除的时候遇到的这个问题,子弹都保存在bullet_list 可
我们编译python代码时, 经常出现各种因为tab和空格的问题, 例如: IndentationError: unindent does not match any outer indentation level 有个简便的办法: 用python的IDLE打开python 代码, 选中所有代码, 点击菜单项Format/Untabify Region
问题:以前使用Pycharm和VsCode没遇到问题,使用nodepat++老是提示Tab异常 TabError: inconsistent use of tabs and spaces in indentation. 查看:视图-显示符号-显示所有字符 解决办法: 1.删除Tab符号,使用空格替代 2.设置-首选项-语言,替换为空格