I would like to start a function with multiple arguments as a new Process using the multiprocess module:
def f(*args):
x= args[0]
y= args[1]
return x+y
p = Process(target=f,args=??)
I would like to know how I can pass the multiple arguments; the documentation as far as I know doesn't mention that.
Using separate arguments:
def f(x,y):
return x+y
if __name__ == '__main__':
p = Process(target=f,args=(1,2,))
p.start()
p.join()
Using *args
syntax:
def f(*args):
x = args[0]
y = args[1]
return x+y
if __name__ == '__main__':
p = Process(target=f,args=(1,2,))
p.start()
p.join()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.