刚才那个代码有误,我把全部贴出来
class intSet(object):
def __init__(self):
# creat an empty set of integers
self.vals = []
def insert(self, e):
# assume e is an interger, and insert it
if not(e in self.vals):
self.vals.append(e)
def member(self, e):
return e in self.vals
def remove(self, e):
try:
self.vals.remove(e)
except:
raise ValueError(str(e) + 'not found')
def __str__(self):
# return a string representation of self
self.vals.sort()
return "{" + ','.join([str(e) for e in self.vals]) + "}"
初学,return后面这一句依然没看懂 .join在这里是method吗, 这个格式是怎么回事
慕虎7371278
慕村225694
蓝山帝景
相关分类