我有一個約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