我无法通过调用pool.map(func,Itable(语法来获得我的功能。我的觉得只不过是每行的数字列表(没有其他逗号含义的值,例如:
LINE01AA1
LINE02AA1
LINE03AA1
LINE04AA1
LINE01AB1
LINE02AB1
LINE03AB1
代码给出了一个错误,就像丢弃的错误:提高self。:
if __name__ == "__main__":
# print ID of current process
print("ID of process running main program: {}".format(os.getpid()))
# print name of main thread
print("Main thread name: {}".format('Main'))
#Start Time
start = time.clock();
q = Queue()
filename = 'test.csv'#load file
load_file(filename)
print("Total Lines Loaded : " + str(len(my_var)))
p = Pool(2)
p.map(getData, my_var)
p.close()
p.join()end = time.clock();
print "The time was {}".format(end - start)
def load_file(filename):
with open(filename, 'rU') as datafile:
for line in datafile:
my_var.append(line.strip())
def getData(number):
print(number)
proc_name = current_process().name
proc = os.getpid()
print("Process:" + proc_name + " PID: " + proc + "Data : " + number)
#set Data
data['r1[]'] = number[:6]
data['r2'] = number[6:]
#print data
response = requests.post('https://somewebsite/post.php', headers=headers, data=data, proxies=proxies)
print response.text
实际上是一个小俯瞰,只是在打印语句中的str((中封装了变量!