python 中 return list 得到none
classalexicon(object):def__init__(self):self.items=[]defscan(self,words):self.word=wo...
class alexicon(object):
def __init__(self):
self.items = []
def scan(self, words):
self.word = words.split()
# direction
self.direction_word = [i for i in self.word if i in self.directions]
self.direction_list = []
for x in self.direction_word:
self.direction_list.append(('direction', '%s' %(x)) )
if self.direction_list != []:
self.items.extend(self.direction_list)
else:
pass
return self.items
为什么执行这个类后得到的都是None。
如果我直接print alexicon.items里是有元素的。 展开
def __init__(self):
self.items = []
def scan(self, words):
self.word = words.split()
# direction
self.direction_word = [i for i in self.word if i in self.directions]
self.direction_list = []
for x in self.direction_word:
self.direction_list.append(('direction', '%s' %(x)) )
if self.direction_list != []:
self.items.extend(self.direction_list)
else:
pass
return self.items
为什么执行这个类后得到的都是None。
如果我直接print alexicon.items里是有元素的。 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询