摘要:
首先举个例子: l=[1,1,1,2,3,4,5] for i in l: if i%2!=0: #把list中的奇数删除 l.remove(i) print(l) #但是运行结果是[1, 2, 4],有奇数没被删掉。 #所以可以看出,循环删list的时候会导致下标错位,结果是不对的。 原因: l= 阅读全文
摘要:
#函数也叫方法,就是实现特定功能的一坨代码,提高代码的复用性。import jsonwith open('a.txt') as f: res=json.load(f)with open('b.txt') as f: res=json.load(f)with open('c.txt') as f: r 阅读全文