为什么痴迷于超pythonic的做事方式?可读性+效率胜过“ leet hackerz风格”。
我只是这样做:
a = [0,0,1,1,1,0,0,1,0,1,1]b = [0,0,0,0,0,0,0,0,0,0,0]for i in range(len(a)): if a[i] == 1: b[i] = b[i-1] + 1 else: b[i] = 0
欢迎分享,转载请注明来源:内存溢出
为什么痴迷于超pythonic的做事方式?可读性+效率胜过“ leet hackerz风格”。
我只是这样做:
a = [0,0,1,1,1,0,0,1,0,1,1]b = [0,0,0,0,0,0,0,0,0,0,0]for i in range(len(a)): if a[i] == 1: b[i] = b[i-1] + 1 else: b[i] = 0
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)