3
为什么csvwriter.writerow()在每个字符后加逗号?
此代码打开url并/names在末尾附加,然后打开页面并将字符串打印到test1.csv: import urllib2 import re import csv url = ("http://www.example.com") bios = [u'/name1', u'/name2', u'/name3'] csvwriter = csv.writer(open("/test1.csv", "a")) for l in bios: OpenThisLink = url + l response = urllib2.urlopen(OpenThisLink) html = response.read() item = re.search('(JD)(.*?)(\d+)', html) if item: JD = item.group() csvwriter.writerow(JD) else: NoJD = "NoJD" csvwriter.writerow(NoJD) 但是我得到这个结果: …