39讲第一题改进
39讲第1题:class Stack:
def __init__(self,start=[]):
self.stack = []
for x in start:
self.push(x)
def look(self):
fot i in self.stack:
retrn self.i
我是想单独自己设立一个look函数,输出【】里面的每个元素 为啥一直报错invalid synax求大佬解答 retrn self.i这是什么鬼 fot 这是什么鬼 class Stack:
def __init__(self, start=[]):
self.stack = []
for x in start:
self.push(x)
def look(self):
for i in self.stack:
return self.i 这粗心程度
{:10_269:} invalid synax大概也打错{:10_249:}应该是invalid syntax翻译翻译就是“无效的语法”{:10_279:} class Struct:
def __init__(self, *args):
self.arr = list(args)
def look(self):
for i in self.arr:
yield i
A = Struct(13, 5, 17, 9, 3)
for i in A.look():
print(i, end = ' ')13 5 17 9 3
页:
[1]