我正在努力使我的一个功能发挥作用。这是它的基础:
#for example:
data=[(b),(c),(d),(e)]
results=[]
for x in data: #this goes through each row of the data
# body_code executes. This part is mostly just changing types, etc
a=final_body_code
results.append(a)
print results
#output should be: results=[(b),(c),(d),(e)] #After changing types of b,c,d,e etc.
#The body of the code does not matter at this point, it's just the appending which i'm
#struggling with.
但是,当我这样做时,它似乎没有将a附加到结果列表中。说到Python我是新手,所以请帮忙!
你应该加上例子。
可能您在
a=final_body_code
中有问题,结果是None
不过,使用list comprehension对@Mrinal Wahal answer进行了一些改进:
我想这是你愿意做的。
相关问题 更多 >
编程相关推荐