Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在python中有没有迭代非类型对象的方法_Python_Python 3.x_Nonetype - Fatal编程技术网

在python中有没有迭代非类型对象的方法

在python中有没有迭代非类型对象的方法,python,python-3.x,nonetype,Python,Python 3.x,Nonetype,当我在线解决python实践问题时,我遇到了这个问题,这个问题不允许我以任何方式迭代函数参数a和b。我需要比较a[0]和b[0] 我尝试过使用生成器、iter函数、类型转换,但似乎都不起作用: def compareTriplets(a, b): if __name__ == '__main__': fptr = open(os.environ['OUTPUT_PATH'], 'w') a = list(map(int, input().rstrip().split()))

当我在线解决python实践问题时,我遇到了这个问题,这个问题不允许我以任何方式迭代函数参数
a
b
。我需要比较
a[0]
b[0]

我尝试过使用生成器、
iter
函数、类型转换,但似乎都不起作用:

def compareTriplets(a, b):

if __name__ == '__main__':
    fptr = open(os.environ['OUTPUT_PATH'], 'w')

    a = list(map(int, input().rstrip().split()))

    b = list(map(int, input().rstrip().split()))

    result = compareTriplets(a, b)

    fptr.write(' '.join(map(str, result)))
    fptr.write('\n')

    fptr.close()

输出总是
None-type对象不可编辑

什么是
compareTriplets
的函数体?现在,这肯定会失败,因为函数甚至不返回任何内容。这就是我必须编写的代码,比较三元组的主体。实际上,a是一种有三个值的列表,b也是,我需要比较它们的值索引,但它不允许我遍历a或b共享完整堆栈跟踪,在这段代码中,你到底在哪里得到了这个错误?好的,让我试试那个MrFuppes@jeetmistry:你需要提供一份;问题出在
compareTriplets
的主体中(您可能忘记了返回任何内容,至少在一条代码路径上),但您未能提供它。在你的问题中编辑它的代码(以及当你在做时的回溯)。