-3
我有以下的代码来生成元组的列表:蟒蛇追加列表回报没有
list_of_tuples = list()
for name in list_of_names:
temporary_list = [name]
date = function_that_return_a_list #like ['2014', '01', '20']
temporary_list = temporary_list + date
print temporary_list #returns the correct list of [name, '2014', '01', '20']
list_of_tuples.append(temporary_list) #crashes with the error message "TypeError: append() takes exactly one argument (0 given)"
print flist
的问题似乎涉及到了追加和插入函数返回None当我尝试使用它们的日期列表
会发生什么:
更好地利用
[]
在任何情况下,产生一个空列表 'list_of_tuples.append(元组(temporary_list))' – RickyA您是否更愿意提供可重现问题的可运行[SSCE](http://sscce.org/)? – bereal
你的代码片段对我来说不会产生错误(当用'['2014','01','20']'替换'function_that_return_a_list'),错误信息也没有意义。你能a)向我们提供异常的* full *追踪和b)实际产生异常的代码示例? –