我需要一个可靠的代码,并且我做了很多相关的测试,似乎它只能序列化字符串而不能序列化sheet对象
from multiprocessing import Pool
import openpyxl
def proxy(cls_instance, index):
return cls_instance.func(index)
class Runner(object):
def __init__(self, obtest, sheet):
self.obtest = obtest
self.sheet = sheet
def func(self, index):
return index
class OBTest(object):
def run(self):
wb = openpyxl.load_workbook('/Users/attackt/Downloads/excelfile.xlsx')
pool = Pool(processes=5)
sheets = wb.worksheets
# sheets = ['A', 'B', 'C', 'D']
result = []
for index, sheet in enumerate(sheets):
instance = Runner(self, sheet)
result.append(pool.apply_async(proxy, (instance, index)))
pool.close()
pool.join()
for data in result:
print data.get()
if __name__ == '__main__':
OBTest().run()
可以在类运行器中定义call()方法,如果类定义call方法,则可以将其实例作为函数调用。在
-
结果:
^{pr2}$或者您可以使用copy\u reg
在
在
什么可以腌制和不腌制
在
如果我的解决方案对你有帮助,请投票表决我的答案。因为我需要解锁我的账户!谢谢!在
请看下面的方法!在
相关问题 更多 >
编程相关推荐