我有一个约1000行的txt文件,我想设置colum 1作为soruce目标,第2列作为传输到目标,并使用shutil.copyfile(src, dst)
复制这些文件。python设置列作为值
我把它设置为一个简单的打印(src,dst),现在我可以看到发生了什么。我在for src in vld
中没有正确地添加linux值。
我是否用这个当前设置取消src值与dst的相应值对齐?我使用Python 2.4
import csv
import operator
import sys
import os
import shutil
inf = csv.reader(open('data.txt','r'))
sortedlist = sorted(inf, key=operator.itemgetter(2), reverse=True)
def dothis(x):
for row in sortedlist:
print row[x]
vld = dothis(0)
linux = dothis(1)
for src in vld:
dst = linux
print (src, dst)
当前的错误消息:
Traceback (most recent call last): File "test.py", line 16, in ? for src in vld:
TypeError: iteration over non-sequence
当前错误消息:“Traceback(最近调用最后一次): 文件”test.py“,第16行,在? for src in vld: TypeError:对非序列的迭代 ' – user1943219