我.writer()
在循环中使用了一个方法,如 Python 文档中所示。我想u
逐行(或更好地逐行)编写变量的结果。
实际上它在解释器中完美运行,但模块writerow()
似乎不起作用。为什么?
from urlparse import urlparse
import csv
import re
ifile =open(ipath,'r')
ofile = open(opath, 'wb')
writer = csv.writer(ofile, dialect='excel')
url =[urlparse(u).netloc for u in file (ipath, "r+b")]
sitesource = set([re.sub("www.", "", e) for e in url])
liste = [re.split(",'", e) for e in liste]
ofile
for row in file (ifile) :
for u in sitesource:
print ("Creation de:", u)
writer.writerow(u)
ofile.close()
我正在使用 Python 2.7。