Discuss / Python / 另一种代码量很少

另一种代码量很少

Topic source

这个必须赞,醍醐灌顶。。。。

湖冰风

#13 Created at ... [Delete] [Delete and Lock User]

谢谢,忽然就明白了java与python的区别

shengscript

#14 Created at ... [Delete] [Delete and Lock User]

真会玩!!!

欢欢No1

#15 Created at ... [Delete] [Delete and Lock User]

流弊,还让我研究一段时间

Henry_Smith

#16 Created at ... [Delete] [Delete and Lock User]

執行后一直报错,什么個情况???

b = [1] while True: ... yield b ... b = [1] + [b[i] + b[i+1] for i in range(len(b)-1)] + [1] ... File "<stdin>", line 2 SyntaxError: 'yield' outside function

童昆Tk

#17 Created at ... [Delete] [Delete and Lock User]

为什么我出现错误 SytaxError:invalid syntax

童昆Tk

#18 Created at ... [Delete] [Delete and Lock User]

SyntaxError: 'yield' outside function

我也是出现这个错误!

赞赞赞

HowyoungZhou

#20 Created at ... [Delete] [Delete and Lock User]

这代码简直漂亮

根据代码理解了一下: 1.list可以相加 2.对于列表生成式[b[i] + b[i+1] for i in range(len(b)-1)]中的b[i] + b[i+1],如果for循环里的参数个数为1,执行的是相加,如果参数个数是2,执行的是[b[i]b[i+1]. 这样对么?


Reply