Python 返回列表结果为“无”

Python 返回列表结果为“无”,python,list,return,nonetype,Python,List,Return,Nonetype,因此,我正在开发一个小程序,通过GUI从给定文件中删除重复项,以学习如何使用Python制作GUI 我已经写了一个方法,它应该接受一个字符串,将它转换成一个列表,从列表中删除重复项,它实际上就是这样做的。 当我想返回结果时会出现问题,因为如果我print()返回值,只会导致打印None。但是如果我print()在方法中返回的值将打印出正确的列表 这个班看起来是这样的: #Class that removes the duplicates class list_cleaner(): def

因此,我正在开发一个小程序,通过GUI从给定文件中删除重复项,以学习如何使用Python制作GUI

我已经写了一个方法,它应该接受一个
字符串
,将它转换成一个
列表
,从
列表
中删除重复项,它实际上就是这样做的。 当我想
返回
结果时会出现问题,因为如果我
print()
返回值,只会导致打印
None
。但是如果我
print()
在方法中返回的值
将打印出正确的列表

这个班看起来是这样的:

#Class that removes the duplicates
class list_cleaner():
    def __init__(self):
        self.result_list = []

    def clean(self,input_string, seperator, target):
        #takes a string and a seperator, and splits the string at the seperator. 
        working_list = self.make_list_from_string(input_string,seperator)

        #identify duplicates, put them in the duplicate_list and remove them from working_list 
        duplicate_list = []
        for entry in working_list:
            instances = 0
            for x in working_list:
                if entry == x:
                    instances =  instances + 1
            if instances > 1:
                #save the found duplicate
                duplicate_list.append(entry)
                #remove the duplicate from working list
                working_list = list(filter((entry).__ne__, working_list))

        self.result_list = working_list + duplicate_list 
        print(self.result_list) #Prints the result list
        return self.result_list
主要功能如下所示(注意:duplicate_remover是list_cleaner的外观):

TL;博士: 我有一个方法
f
返回
list
l
,它是类
C
的一个属性

如果i
print()
l
作为
f
的一部分,则打印
l
的值

如果我返回
l
并将其存储在
f
范围之外的变量中,然后
print()
此变量将打印
None

提前谢谢

编辑1: 请求了
replicate\u remover
代码。 看起来是这样的:

class duplicate_remover():
    def remove_duplicates(self,input_string,seperator):
        my_list_cleaner = list_cleaner()
        my_list_cleaner.clean( input_string = input_string, seperator = seperator)

remove\u duplicates
忘记返回
my\u list\u cleaner.clean(…)
的返回值,这导致返回默认值
None

看起来像是
duplicate\u remover
是罪魁祸首。我现在将发布duplicate\u remover:)(试图将其添加到此注释中,但格式不正确)请把它编辑成你的问题。我不敢相信这是答案。。。非常感谢!我现在就去给自己挖个洞。。。
class duplicate_remover():
    def remove_duplicates(self,input_string,seperator):
        my_list_cleaner = list_cleaner()
        my_list_cleaner.clean( input_string = input_string, seperator = seperator)