Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/17.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/list/4.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 3.x 获取属性错误:';非类型';对象没有属性';追加';在循环中使用列表时,该列表在循环外声明_Python 3.x_List_Append_Attributeerror - Fatal编程技术网

Python 3.x 获取属性错误:';非类型';对象没有属性';追加';在循环中使用列表时,该列表在循环外声明

Python 3.x 获取属性错误:';非类型';对象没有属性';追加';在循环中使用列表时,该列表在循环外声明,python-3.x,list,append,attributeerror,Python 3.x,List,Append,Attributeerror,'当我运行下面的代码时,我得到以下错误。 AttributeError:“非类型”对象没有属性“附加” 请帮帮我。我是Python的新手 大宗报价 list.append(x)修改列表本身并返回None,因此 为x1分配None,并且在下一次迭代中遇到错误。只要写 x1.append(x[i]) 相反 x1=x1.append(x[i]) x1.append(x[i])

'当我运行下面的代码时,我得到以下错误。 AttributeError:“非类型”对象没有属性“附加” 请帮帮我。我是Python的新手

大宗报价

list.append(x)
修改列表本身并返回None,因此

为x1分配None,并且在下一次迭代中遇到错误。只要写

        x1.append(x[i])
相反

        x1=x1.append(x[i])
        x1.append(x[i])